重写rest delete

阅读更多

第一种:

@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;

    // ...

}

你可能感兴趣的:(rest,jpa,重写delete)