Skip to content

Hibernate 7: a later alias of an association path keeps the join of its own (#16773 follow-up) - #16914

Merged
borinquenkid merged 1 commit into
8.0.xfrom
fix/h7-second-alias-own-join-8.0.x
Nov 11, 2026
Merged

borinquenkid merged 1 commit into
8.0.xfrom
fix/h7-second-alias-own-join-8.0.x

Conversation

@borinquenkid

Copy link
Copy Markdown
Member

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') and createAlias('likes', 'second') followed by eq('second.tag.name', 'b') resolved tag through the join the path likes.tag belongs 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. CreateAliasJoinSpec gains 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

…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
borinquenkid requested review from jamesfredley and a balanced review from Copilot November 10, 2026 03:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@testlens-app

testlens-app Bot commented Nov 10, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: dd1d3c8
▶️ Tests: 94301 executed
⚪️ Checks: 94/94 completed


Learn more about TestLens at testlens.app/docs.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A restriction on a second alias of the same association uses that alias's own join.

@borinquenkid
borinquenkid merged commit 1d3db67 into 8.0.x Nov 11, 2026
95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants