-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DATAJPA-1418 Interface-based Projections - Generate inner join instead of left join #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
schauder
pushed a commit
that referenced
this pull request
Oct 17, 2018
…ead of left join. When a projection contains a reference to an entity we generate an outer join again. This is necessary since Hibernate insist on creating an inner join instead, which will filter out null values of the reference. See also: https://hibernate.atlassian.net/browse/HHH-12999. See also: jakartaee/persistence#189. Original pull request: #294.
schauder
added a commit
that referenced
this pull request
Oct 17, 2018
Added comment with issue id on the test. Added a comment with a link to the Hibernate issue. Original pull request: #294.
schauder
pushed a commit
that referenced
this pull request
Oct 17, 2018
…ead of left join. When a projection contains a reference to an entity we generate an outer join again. This is necessary since Hibernate insist on creating an inner join instead, which will filter out null values of the reference. See also: https://hibernate.atlassian.net/browse/HHH-12999. See also: jakartaee/persistence#189. Original pull request: #294.
schauder
added a commit
that referenced
this pull request
Oct 17, 2018
Added comment with issue id on the test. Added a comment with a link to the Hibernate issue. Original pull request: #294.
schauder
pushed a commit
that referenced
this pull request
Oct 17, 2018
…ead of left join. When a projection contains a reference to an entity we generate an outer join again. This is necessary since Hibernate insist on creating an inner join instead, which will filter out null values of the reference. See also: https://hibernate.atlassian.net/browse/HHH-12999. See also: jakartaee/persistence#189. Original pull request: #294.
schauder
added a commit
that referenced
this pull request
Oct 17, 2018
Added comment with issue id on the test. Added a comment with a link to the Hibernate issue. Original pull request: #294.
Thanks, that is merged. |
Thanks :) |
stsypanov
pushed a commit
to stsypanov/spring-data-jpa
that referenced
this pull request
Dec 13, 2019
…ead of left join. When a projection contains a reference to an entity we generate an outer join again. This is necessary since Hibernate insist on creating an inner join instead, which will filter out null values of the reference. See also: https://hibernate.atlassian.net/browse/HHH-12999. See also: jakartaee/persistence#189. Original pull request: spring-projects#294.
stsypanov
pushed a commit
to stsypanov/spring-data-jpa
that referenced
this pull request
Dec 13, 2019
Added comment with issue id on the test. Added a comment with a link to the Hibernate issue. Original pull request: spring-projects#294.
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the PR is accepted, I think a merge to 2.0.x is needed.
By default, when a foreign entity, without further sub attribute, is involved, Hibernate generates an inner join on the table of the foreign entity. Hibernate internals do this before processing the EntityGraph. So even when the final SQL query only fetch the foreign entity ID hold by the primary table, it joins on the foreign table. I don't think Hibernate is going to change this behaviour before 6.0.
The current bug was introduced by DATAJPA-1238 fix. The goal of DATAJPA-1238 was to avoid a useless left outer join when a foreign entity was involved in the query predicate (findByX where X is an entity). Its fix removed the outer join when the navigated foreign entity was a leaf, regardless of the location of the property representing the entity.
My pull request creates a distinction between properties navigated inside the select clause and other properties (i.e. navigated in the predicate). If the entity property is a leaf outside a select clause, DATAJPA-1238 fix is kept, no outer join is generated. If the property is a leaf inside a select clause, an outer join is created as it was before DATAJPA-1238 fix.