I am making an application based on JPA/EclipseLink, I implemented a soft delete functionality using @AdditionalCriteria in the root class of the hierarchy of entities (all entities inherit from this).
My problem is that now, I need to create a special entity that contains multiple relationships with other entities; and I need recover all relationed entities, including soft deleted ones. It is possible disabled @AdditionalCriteria only in the relations of this special entity with EclipseLink? If not, what is the best option to do this? My code looks like the following:
////Example of my top entity class (all others inherit from this)
@AdditionalCriteria("this.deleted = false")
public abstract class TopHierarchyClass {
···
@Column(name = "deleted")
protected boolean deleted = false;
···
}
//Example of entity that needs recover all relationed entities including soft deleted
@Entity
@Table(name = "special_entities")
public class SpecialEntity extends EntityBase {
···
@JoinColumn(name = "iditem", referencedColumnName = "id")
@ManyToOne(fetch = FetchType.LAZY)
private Item item;
···
}
@Entity
@Table(name = "items")
public class Item extends EntityBase {
···
}
Thanks in advance