Soft delete using @MappedSuperClass in sleep mode

I have an abstract base class Athat is @MappedSuperClass. In addition, there are several classes of entities that extend from the class A. The class Acontains an attribute STATUSthat represents the deletion of the record or not.

@MappedSuperclass
public abstract class A {

    @Id
    private Long id;

    @Column(nullable = false)
    private boolean status = true;

}

I want to be able to perform soft deletion on all child classes from a class Awith annotation @SQLDelete. For example, I have a class B extends Aand whenever I call delete in the class B, I want it to update the status of this record in the database.

@Entity
@Table(name = "TempTable")
@SQLDelete(sql = "update TempTable set STATUS = 0 where ID = ?")  //Basically, I don't want 
                                                                  //to write this in every 
                                                                  //class. Instead write 
                                                                  //it to class A once.
@Where(clause = "STATUS = 1")
public class B extends A {
    private String alpha;
}

, @SQLDelete . A . .

? , ?

.

+4

Source: https://habr.com/ru/post/1662610/


All Articles