目前软删除实现看起来像这样
父类
@MappedSuperclass
public abstract class ParentClass {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
private boolean archived = false;
}
儿童等级1
@Entity
@SQLDelete(sql = "UPDATE child_class1 SET archived = 1 WHERE id = ?")
@Where(clause = "is_archived = 'false'")
public class ChildClass1 extends ParentClass {
...
...
}
儿童班2
@Entity
@SQLDelete(sql = "UPDATE child_class2 SET archived = 1 WHERE id = ?")
@Where(clause = "is_archived = 'false'")
public class ChildClass2 extends ParentClass {
...
...
}
正如您所见,SQLDelete&哪些条款重复,查询中的细微差别。有没有办法概括它们并能够将它们放在ParentClass中?
之类的东西@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;
}
我确实尝试过上述更改,但是hibernate没有在获取或删除实体上应用这些注释。