Skip to content

Hibernate 7: the fetch mode join of list() keeps the instances whose association is null or empty - #16898

Merged
borinquenkid merged 1 commit into
8.0.xfrom
fix/h7-list-fetch-join-keeps-null-8.0.x
Nov 9, 2026
Merged

borinquenkid merged 1 commit into
8.0.xfrom
fix/h7-list-fetch-join-keeps-null-8.0.x

Conversation

@borinquenkid

Copy link
Copy Markdown
Member

Team.list(fetch: [club: 'join']) built join fetch, an inner join, so it left out the teams without a club. A where query, a dynamic finder and a criteria query with the same fetch return every team. list() and a paged list now build left join fetch, so the fetch mode join fetches and never filters. A join type (JoinType.INNER) stays the way to ask for the filter.

This is the Hibernate 7 half of the question jdaugherty raised on #16853; the Hibernate 5 half is on that PR (1e475136f4). Behavior is the same on both after the two.

ListFetchJoinNullSpec runs the fetch mode join on a nullable association and on an empty collection for list, a paged list, a where query and a dynamic finder; the list cases fail without the change. The H7 core suite passes.

…in and keeps the instances whose association is null or empty

list() and a paged list built 'join fetch', an inner join, so Team.list(fetch: [club: 'join']) left out the teams without a club, while a where query and a dynamic finder returned every team. It now builds 'left join fetch', as the join type LEFT does; only a join type asks for the instances to be left out. ListFetchJoinNullSpec runs the fetch mode join on an association that can be null and on a collection that can be empty for list, a paged list, a where query and a dynamic finder; the list cases fail without the change.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
Copilot AI balanced review requested due to automatic review settings November 8, 2026 22:15

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.

@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 fetch join of list() now keeps the instances whose association is null or empty.

@borinquenkid
borinquenkid merged commit 16a3093 into 8.0.x Nov 9, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants