To switch from an eclipse link to hibernate, I am looking for the equivalent of annotating an eclipse link @AdditionalCriteriain Hibernate at the level @MappedSupperClass BaseEntityto filter logically deleted entries from all objects extending this one BaseEntity.
I found the annotation @Where. But this only works at the level Entity, not in BaseEntity. Please let me know if it is possible to add this or any other Hibernate annotation for filtering BaseEntity.
@MappedSuperclass
@Where(clause = "DEL_IND = 0")
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")
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
--------------------
--------------------
}
source
share