For migrating from eclipse link to hibernate, I am looking for the equivalent of eclipse link annotation @AdditionalCriteria
in Hibernate at @MappedSupperClass
BaseEntity
level, to filter logically deleted records from all entities extending this BaseEntity
.
I had found @Where
annotation. But, this only works at Entity
level and not at BaseEntity. Please let me know if there is any possibility to add this or any other Hibernate annotation to filter 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
--------------------
--------------------
}