Repository navigation
Hibernate 7: a later alias of an association path keeps the join of its own (#16773 follow-up) - #16914
Merged
Conversation
…of its own
createAlias('likes', 'first') and createAlias('likes', 'second') followed by
eq('second.tag.name', 'b') resolved the dotted property below the second alias
through the join that the path likes.tag belongs to, which is the first alias's,
so a team whose likes split the two restrictions was missing.
Only the first alias of a path shares the join of the path. A dotted property
below a later alias now continues from the join of that alias.
A second spec, a subquery that compares with a dotted property of the second outer
alias, passes before and after: it is kept as a regression test.
Follow-up to #16773, reported in its review by James Fredley.
Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
borinquenkid
requested review from
jamesfredley
and
a balanced review from Copilot
November 10, 2026 03:52
✅ All tests passed ✅🏷️ Commit: dd1d3c8 Learn more about TestLens at testlens.app/docs. |
jamesfredley
approved these changes
Nov 10, 2026
jamesfredley
left a comment
Contributor
There was a problem hiding this comment.
A restriction on a second alias of the same association uses that alias's own join.
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
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.
Follow-up to #16773 (issue #16562). James Fredley's last review found that a dotted restriction on a second alias of the same association still followed the first alias.
The bug.
createAlias('likes', 'first')andcreateAlias('likes', 'second')followed byeq('second.tag.name', 'b')resolvedtagthrough the join the pathlikes.tagbelongs to, which is the first alias's. A team whose likes split the two restrictions was missing.The fix. Only the first alias of a path shares the join of the path. A dotted property below a later alias now continues from the join of that alias.
Tests.
CreateAliasJoinSpecgains James's input: it returned[]before and returns the team now. It also checks the swapped alias order and that one alias alone restricts only its own join. A second case, a subquery that compares with a dotted property of the second outer alias, passes before and after the change: I could not reproduce that half of the finding, and it is kept as a regression test. H7 core: 4,612 tests, 0 failures. Checkstyle and CodeNarc clean.This touches the same method as #16891. The two merge cleanly, and the alias specs pass on the two together.
https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL