Left join with exists subquery adds extra join

Description

Having two unrelated entities:

And the Property:

We are trying to get both Entities, but left join only the Entities that have a specific Property:

So we are interested only in the Entity2 that have a Property named admin. This is just an example, our actual use case is more complicated.

This was working fine before Hibernate 6, generating the following query:

But with Hibernate 6, another join is added at the end which duplicates the results and breaks the left join:

Join that has no purpose:

Created test cases for both Hibernate 5 and 6:

Activity

Show:
Fixed

Details

Assignee

Reporter

Worked in

Components

Sprint

Fix versions

Affects versions

Priority

Created July 4, 2023 at 12:54 PM
Updated August 31, 2023 at 5:30 PM
Resolved August 1, 2023 at 11:42 AM