Is there a way to disable @AdditionalCriteria in EclipseLink?
eclipselink
Solution
Yes, it's possible, with an easy workaround. I specified the @AdditionalCriteria annotation like this:
@AdditionalCriteria(":disableDeletedFeature = 1 or this.isDeleted = false")
and specified a default property value for the disable flag in the persistence.xml:
<property name="disableDeletedFeature" value="0"/>
so by default filtering is enabled but you can disable it easily at the EntityManager level like this:
entityManager.setProperty("disableDeletedFeature", 1);
It works all fine for me, hope it helps!
Problem
It's easy to use @AdditionalCriteria in EclipseLink for example to filter out soft deleted entities but is there any way disable it temporarily before executing a specific query?