Repository navigation
Hibernate 7: the fetch mode join of list() keeps the instances whose association is null or empty - #16898
Conversation
…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
jamesfredley
left a comment
There was a problem hiding this comment.
A fetch join of list() now keeps the instances whose association is null or empty.
The fetch mode join of a list query is a left join (#16898), also where the query sorts through the fetched association and the fetch shares its alias. The upgrade guide entry about sorting by an association follows the entry about exception mappings. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
This changes which rows Hibernate 5 still leaves those rows out on 8.0.x, because its I agree the new behavior is the right one: a fetch mode should decide how an association is loaded, not which rows come back. But like the Hibernate 5 half, it's a behavior change, and since Grails 8 has shipped, it belongs in Grails 9. I'd like to revert it on 8.0.x before 8.0.1 is released, and keep it on 9.0.x when the revert is merged up, so it lands in Grails 9 together with the Hibernate 5 half. If you'd rather keep it in 8.0.1, it needs an upgrade note at least, and the note should say that Hibernate 5 still leaves the rows out. |
|
Filed #16939 for this, with a revert on 8.0.x (PR coming) that keeps the change on 9.0.x. |
Team.list(fetch: [club: 'join'])builtjoin 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 buildleft join fetch, so the fetch modejoinfetches 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.ListFetchJoinNullSpecruns the fetch modejoinon a nullable association and on an empty collection forlist, a paged list, a where query and a dynamic finder; thelistcases fail without the change. The H7 core suite passes.