Missing aliases when executing a query with join and involving an entity with inheritance type JOINED

Description

When executing a query with join and involving an entity with inheritance type JOINED, it fails because it provides aliases in select list also for the JOINED entity, but this entity is not joined.

Example:

With the described structure, it is not possible to define a query such as:

select d from TestSpecializedEntity e join e.details d where e.id = :id

It fails because it is generating the following SQL statement:

Alias tse1_1 is used in select list, but it is never declared.

Correct query should also include:

as it did up to 6.2.2.Final.

Might be related in some way to .

Test case

Activity

Show:

Andrea Turri April 12, 2024 at 8:25 AM

Hello, thanks for quick feedback. Great!

Marco Belladelli April 12, 2024 at 7:15 AM

Hello, thank you for reporting the issue and providing a reproducer. I’ve ran your test case against the latest Hibernate 6.5 snapshot and confirmed this error was also solved by the fix for . If you want to test for yourselves, you can find the snapshots at this repository: https://oss.sonatype.org/content/repositories/snapshots/.

Andrea Turri April 11, 2024 at 4:10 PM

Thanks . I’ve pushed in repository a test case also for the query you provided.

Fabio Paini April 11, 2024 at 3:43 PM

Given those entities, the same problem arises even without parameters and with an implicit join: select e.details from TestSpecializedEntity e.

Out of Date

Details

Assignee

Reporter

Worked in

Affects versions

Priority

Created April 11, 2024 at 3:12 PM
Updated April 12, 2024 at 8:25 AM
Resolved April 12, 2024 at 7:16 AM