Using type function on association in HQL results in SQL checking base entity's type

Description

Entities:

I'm executing this query (with maxResults=1):

This results in the following SQL:

I expected an implicit join on the parent association, but instead it checks entityId on the base table.

But if I use the old class syntax:

Then it does what I expected:

Environment

Wildfly 15.0.1.Final

Activity

Show:
Christian Beikov
January 13, 2021, 10:07 AM

Thanks for the report. I guess the problem is that Hibernate doesn’t do the implicit join for the parent association which then leads to this wrong behavior. I bet if you use inner join parent p where type(p) = SupervisedTerritory this should work properly.

Vsevolod Golovanov
January 13, 2021, 10:23 AM

Yes, explicit join works fine.

Assignee

Unassigned

Reporter

Vsevolod Golovanov

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure