Currently soft delete implementation looks like this
Parent class
@MappedSuperclass
public abstract class ParentClass {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
private boolean archived = false;
}
Child Class 1
@Entity
@SQLDelete(sql = "UPDATE child_class1 SET archived = 1 WHERE id = ?")
@Where(clause = "is_archived = 'false'")
public class ChildClass1 extends ParentClass {
...
...
}
Child class 2
@Entity
@SQLDelete(sql = "UPDATE child_class2 SET archived = 1 WHERE id = ?")
@Where(clause = "is_archived = 'false'")
public class ChildClass2 extends ParentClass {
...
...
}
As you can see, SQLDelete & Where clauses are getting repeated with minor difference in query. Is there a way to generalize them and be able to put them in ParentClass? something like
@MappedSuperclass
@SQLDelete(sql = "UPDATE <what_would_come_here> SET archived = 1 WHERE id = ?")
@Where(clause = "is_archived = 'false'")
public abstract class ParentClass {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
private boolean archived = false;
}
I did try above changes but hibernate didn't apply these annotations on get or delete entities.