Hibernate Filter is not applied to entities brought in by an unassociated outer join
Description
Hibernate 5.2 added support of JPA unassociated outer join feature, i.e., queries with outer joins between entities that don't have references to each other. However, Hibernate Filters defined through @FilterDef/@Filter don't get properly applied to entities brought in by the outer joins.
In the attached example, we have a BookEntity and a MovieEntity, both having a "name" column and an "active" column. An activeFilter is defined to limit queries to return only rows that are active:
It's applied to both BookEntity and MovieEntity.
Now we have a query with outer join from BookEntity to MovieEntity:
Although the query result contains only active BookEntities, it includes inactive MovieEntities in addition to active ones, which indicates that the filter is not applied to the latter, as opposed to the inner join situation, where the filter is applied to both. Outer joins though associated entities do work properly.
Here is the SQL that Hibernate generates:
Note that movieentit1_.active=1 is missing from the raw SQL.
Hibernate 5.2 added support of JPA unassociated outer join feature, i.e., queries with outer joins between entities that don't have references to each other. However, Hibernate Filters defined through @FilterDef/@Filter don't get properly applied to entities brought in by the outer joins.
In the attached example, we have a BookEntity and a MovieEntity, both having a "name" column and an "active" column. An activeFilter is defined to limit queries to return only rows that are active:
It's applied to both BookEntity and MovieEntity.
Now we have a query with outer join from BookEntity to MovieEntity:
Although the query result contains only active BookEntities, it includes inactive MovieEntities in addition to active ones, which indicates that the filter is not applied to the latter, as opposed to the inner join situation, where the filter is applied to both. Outer joins though associated entities do work properly.
Here is the SQL that Hibernate generates:
Note that movieentit1_.active=1 is missing from the raw SQL.