休眠@Where未在实体@MappedSuperClass强制执行
为了从 eclipse link 迁移到 Hibernate,我正在寻找相当于 Hibernate 中的 eclipse link annotation at level,以过滤来自扩展此内容的所有实体的逻辑删除记录。@AdditionalCriteria
@MappedSupperClass
BaseEntity
BaseEntity
我找到了注释。但是,这仅适用于级别,而不适用于基本实体。请让我知道,如果有任何可能性添加这个或任何其他休眠注释来过滤。@Where
Entity
BaseEntity
@MappedSuperclass
@Where(clause = "DEL_IND = 0") // DOES NOT WORK
public abstract class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "DEL_IND")
private boolean deleted = Boolean.FALSE;
public boolean getDeleted() {
return deleted;
}
public void setDeleted() {
this.deleted = Boolean.TRUE;
}
}
@Entity
@Table(name = "PERSON")
@Where(clause = "DEL_IND = 0") // THIS WORKS BUT NEEDS TO BE REPEATED IN ALL ENTITIES
public class Person extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
@Column(name = "PERSON_ID")
private Integer id;
@Column(name = "LAST_NAME")
private String lastName;
@Column(name = "FIRST_NAME")
private String firstName;
--------------------
getters & setters
--------------------
--------------------
}