---
title: "重写rest delete"
author: "e_e"
date: "2019-03-04T11:32:20Z"
tags: []
categories: ["开源软件"]
slug: "rest-delete"
draft: false
lastmod: "2019-03-04T11:35:21Z"
id: 2438377
url: "https://e-e.iteye.com/blog/2438377"
---

第一种：

@Transactional

@Modifying

@Query(value = "UPDATE UserPO SET voided = 1 where id = ?1")

@Override

void deleteById(@NotNull Long userId);

 

第二种：（更底层）

@Entity

@Table(name="TABLE")

@ActionOverride(action="delete", with="activeFlag = false")

public class Table {

    @Column(name="ACTIVE\_FLAG")

    boolean activeFlag;

    // ...

}

或者

@Entity

@Table(name="TABLE")

@SQLDelete(sql = "UPDATE TABLE SET ACTIVE\_FLAG = false WHERE id = ?")

public class Table {

    @Column(name="ACTIVE\_FLAG")

    boolean activeFlag;

    // ...

}