SQLGrammarException for JOINED entity with additional join in query

Description

Constellation / Problem

I have the following entities/objects

  • MasterEntity

  • ChildEntity

  • RelatedEntity

  • ChildPojo (used for the query)

See

(unfortunately I cannot upload any pictures to this Jira board)

 

The MasterEntity has the interhitance strategy JOINED.

The ChildEntity extends the MasterEntity and has a (bi-directional) one-to-many relatio to RelatedEntity.

 

Additionally there is a ChildPojo, which is used in a criteria query.

When executing now a query with a join to RelatedEntity, then I get an exception, as it looses the join to the MasterEntity.

 

Criteria Query

 

Generated Query

Here the join to the MasterEntity is missing.

 

Exception (tries to get a field for a not known alias)

 

Without the (manual) join, the query looks like expected (but of course without the needed join to the RelatedEntity):

 

In Hibernate 5.6.15.Final the same constellation (with the additional join) works fine:

 

I created two reproducers for this - one with Hibernate 5 and one with Hibernate 6. Both uses Quarkus, but the error can also be reproduced with “plain” Hibernate.

Simply execute a mvn clean install and you will get the error for the Hibernate 6 project. The Hibernate 5 project works as expected.

  • Reproducer Hibernate 6:

  • Reproducer Hibernate 5:

 

Hint: Possibly this is related to

is duplicated by

Activity

Show:
Fixed

Details

Assignee

Reporter

Worked in

Components

Fix versions

Affects versions

Priority

Created July 24, 2023 at 9:44 AM
Updated August 31, 2023 at 5:28 PM
Resolved August 2, 2023 at 5:02 PM