Usage of the @Where annotation on a collection that contains entities that make use of JOINED inheritance strategy results in incorrect SQL.
Hibernate is assuming that the column specified in the @Where annotation will always be on the table that belongs to the entity in the collection, instead of also checking the super-class tables.
For example, consider the following data model and mapping code:
Loading Application will issue incorrect SQL, where PROJ_VSN_EFF_TO_DTM is being referenced on the DFIP_APPLN_PROJ_VERSION table, rather than its super-class (DFIP_PROJECT_VERSION).
A unit test demonstrating the issue is attached.
I have the exact problem with my Hibernate version 5.1.12.Final with JPA
My superclass has @MappedSuperClass, and @Where annotation is not inherited from it, I need to duplicate same silly annotation for hundreds of entities that are all extending same base entity.
@Inheritance is hard to use in serious cases - envers doesn't work (HHH-9770), @where doesn't work (useful also for soft delete).