Repository navigation
Apply a requested join type with Hibernate 7 - #17079
jdaugherty wants to merge 163 commits into
Conversation
A where query, a detached criteria, a dynamic finder or a criteria query can request the type of the join of an association, with the fetch argument, with join(association, JoinType) or with @Join. Hibernate 7 applied it to the list of a query that requests it for an association of the queried class and otherwise ignored it. A join type other than a left join is now applied whether or not anything else in the query uses the association, as GORM for Hibernate 5 applies it on 7.0.x: - count and the totalCount of a paged list count the instances that the list returns, also for a collection, a collection of a basic type and a right join; - a path through more than one association joins and fetches every association on it, and a path that ends in or passes through a collection restricts the query with a correlated subquery, so each instance is returned and counted once and a fetched collection keeps all of its elements; - a subquery and a property projection apply it; - updateAll and deleteAll apply it as a restriction, and reject a path that selects from the modified table on MySQL and on MariaDB before 10.3; - list, findWhere, findAllWhere and the example queries apply a join type in their fetch argument, by running as a criteria query; - the fetch argument of the list of a criteria query is applied; it was ignored; - in a criteria query, join(association) and select(association) are fetch modes, as they are in a where query: join applied an inner join and select returned the association instead of the instances; - a fetch mode requested after a join type replaces it, while the join that criteria on the association make keeps the join type. The change to AbstractDetachedCriteria and DynamicFinder for this is the one that the Hibernate 5 pull request makes on 7.0.x; - a join type requested for a property that is not an association is ignored instead of failing. AssociationJoinTypeSpec is the specification of the Hibernate 5 change, with the expectations that describe the Hibernate 5 engine adjusted: a criteria query returns an instance once, and a projection of one property is not made distinct.
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A join of a collection of basic values deletes the collection rows and leaves the owners.
|
6de9334 brings in the reviewed fixes from the parent, #16863. The combined branch now passes the complete Hibernate 7 core suite and the required aggregate checks: the final combined report contains 26,624 tests, zero failures/errors and 472 skipped. Checkstyle, CodeNarc, repository conventions, enabled PMD checks and RAT pass; SpotBugs is disabled. The Hibernate 5 review fixes have also been carried through the dependent split branches, with the combined Hibernate 5 core suite passing. The agreed merge order remains: this Hibernate 7 rule and spec must be on 8.0.x before the requested-join parts merge into 7.0.x. |
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A block overwrites a left join the call asked for.
matrei
left a comment
There was a problem hiding this comment.
Reviewed at 6de9334 (base 8.0.x): e7fbf6e, b5fecc8 and the merge of #16863's head (87594ea), which merges without a conflict. I ran with Hibernate 7 the probes of my reviews of #17067 to #17074, about 300 queries, with grails.gorm.leftJoinAssociationSort off and on:
- at this head and at #16863;
- compared with 8.0.x (0518f48) and with Hibernate 5 at the top of the 7.0.x stack (#17073, 16bd465).
Against #16863, every result that changes moves to the result of the Hibernate 5 stack, except in points 1, 2 and 4. For example:
| 8.0.x | #16863 | This head | Hibernate 5 stack | |
|---|---|---|---|---|
Player.where { … }.join('team.club', JoinType.INNER).list(), also a criteria query |
7 players | 7 | 6 | 6 |
Team.list(fetch: [club: JoinType.INNER]) |
7 teams | 7 | 5 | 5 |
Team.createCriteria().list(fetch: [club: JoinType.INNER]) { … } |
5 | 5 | 4 | 4 |
Team.where { … }.join('club', JoinType.INNER).updateAll(…) |
5 updated | 5 | 4 | 4 |
Team.where { … }.join('players.contract', JoinType.INNER).updateAll(…) |
7 | 7 | 4 | 4 |
deleteAll with an inner join of a unidirectional collection |
2 deleted | 2 | 1 | 1 |
Team.where { … }.join('club', JoinType.INNER).select('club').list() |
3 clubs instead of teams | 3 clubs | 5 teams | 5 |
Team.createCriteria().list { join('club', JoinType.INNER); join('club') } |
4 | 4 | 5 | 5 |
A paged list that fetches a collection through a path, as in fetch: ['players.contract': JoinType.INNER] with max: 2, fetches the team with all three of its players here. That's the result that I asked Hibernate 5 to have, in point 1 on #17067. I agree that this needs no setting, by #17061, and that the Hibernate 5 parts wait for it.
The tests pass at this head: grails-data-hibernate7-core has 5076 tests, 44 skipped, and grails-datamapping-core 1836 tests, 2 skipped.
Needs a fix
1. With discriminator multi-tenancy, deleteAll through a join table deletes an instance that list leaves out. Cases that aren't multi-tenant, with items that are, in a unidirectional collection. Under one tenant:
Case.where { name ==~ '%case' }.join('items', JoinType.INNER) |
8.0.x and #16863 | This head | Hibernate 5 stack |
|---|---|---|---|
list() |
1 case | 1 | 1 |
updateAll(name: 'X') |
3 | 1 | 1 |
deleteAll() |
3 | 2 | 1 |
The second case that deleteAll deletes has only an item of the other tenant. updateAll matches the one case, so the restriction with the tenant filter is right. The identifiers that deleteByIdentifiers selects first aren't, so the select seems to run without the filter of the subquery. Hibernate 5 deletes the one case.
2. A subquery's join type isn't applied to updateAll and deleteAll, as in point 3 on #17068. Since this head, list applies the join type of a subquery, and the bulk operations still don't:
| #16863 | This head | |
|---|---|---|
new DetachedCriteria(Team).inList('id', Team.where { name ==~ '%First%' }.join('club', JoinType.INNER).id()): list / updateAll |
5 / 5 | 4 / 5 |
the same for deleteAll with two teams, one without a club: list / deleteAll |
2 / 2 | 1 / 2 |
Player.where { team in Team.where { … }.join('club', JoinType.INNER) }: list / updateAll |
4 / 4 | 3 / 4 |
At #16863 these agreed. Now updateAll changes rows that list leaves out.
3. A join type requested inside the block of an association is ignored. Player.createCriteria().list { team { join('club', JoinType.INNER) } } returns all 7 players here, while join('team.club', JoinType.INNER) returns 6. The Hibernate 5 stack returns 6 for both.
4. James's latest comment holds: in a criteria query, the order of join and the block of the association decides the join type.
Team.createCriteria().list { like('name', '%First%'); … } |
This head | Hibernate 5 stack |
|---|---|---|
join('club', JoinType.LEFT); club { order('name') } |
4 teams | 4 |
club { order('name') }; join('club', JoinType.LEFT) |
5 | 4 |
club { order('name') } with list(fetch: [club: JoinType.LEFT]) |
5 | 4 |
or { club { eq('name', 'Chelsea') }; eq('name', 'Unattached First Team') }; join('club', JoinType.LEFT) |
3 | 2 |
Hibernate 5 keeps the inner join of the block in every order, and I asked it to use the requested type instead, in point 1 on #17069. Here the requested type wins when it comes after the block, and loses when it comes before it. Whichever of the two is kept, both modules need it in any order.
5. A bag holds repeated elements. Members are a bag, trophies a set, and the team has two members:
| 8.0.x | This head | Hibernate 5 stack | |
|---|---|---|---|
Team.where { members { name == 'a' } }.join('members', JoinType.LEFT).join('trophies').list() |
the bag holds 4 members | 4 | 2, loaded when read |
Team.list(sort: 'trophies.title', fetch: [members: 'join']), with the setting off and on |
fails | 4 | 4 with the setting off; throws with it on |
The first comes from 8.0.x, and the Hibernate 5 stack fixes it in #17072. The second comes from #16863, where a sort by a collection starts to work. In both, the session holds a collection with elements that aren't there.
6. Player.list(fetch: ['team.players': 'join'], max: 2) fails with Query specified join fetching, but the owner of the fetched association was not present, on 8.0.x and here. The Hibernate 5 stack returns the 2 players, with the team's players fetched. This is the fetch argument of list, which this pull request ports from #17071.
7. Resolve the conflicts with 8.0.x. upgrading80x.adoc conflicts, as #16863 does. No check has run for b5fecc8 or for this head, so the green run is the one of e7fbf6e.
Notes
-
The description lists three results that differ from Hibernate 5 on purpose. The first two are a criteria query that returns an instance once, and a property projection that isn't distinct. #17061 counts a Hibernate 7 result that differs from Hibernate 5 as a regression, so the migration from Hibernate 5 to Hibernate 7 in the guide should name them. The same holds for these, which my probes found:
order('players.name')andTeam.list(sort: 'players.name')return the team once here, and once for each player with Hibernate 5;- a right join: here
listhas anullfor each club that no team refers to, andTeam.list(fetch: [club: JoinType.RIGHT])has thenullas well, where Hibernate 5 has onenull(point 2 on #17067) and applies an inner join (point 2 on #17071); - a projection of a property of an association leaves out the rows without the association (note 8 on #17066).
-
The
countand thetotalCountof a sort through an association leave out the join of the sort, so they count the teams without a club that the list leaves out. For example,Team.createCriteria().list(sort: 'club.name') { like('name', '%First%') }returns 4 teams with atotalCountof 5. That's #16863's, which I noted on #17064. -
This pull request ports #17067, #17068, #17069 and #17071. The other parts of the stack change Hibernate 5 only, and Hibernate 7 returns other results for them:
- #17070: a map of sort properties in a criteria query fails with a
ClassCastException, here and on 8.0.x; - #17072: no exception for a sort by a bag next to the fetch of another collection;
- #17073: a sort by the alias of the queried class fails with
Invalid sort property; - #17074 on 9.0.x: other exceptions for an undefined alias.
The merge-up then leaves the two modules apart there. They need a counterpart here or in a pull request of its own, before those parts merge.
- #17070: a map of sort properties in a criteria query fails with a
-
Team.findAll(new Team(), [sort: 'x.name'])and[sort: 'this.name']returnnullwith Hibernate 7, here and on 8.0.x, wherelistfails withInvalid sort propertyfor the same sorts. That's a bug of its own. -
AbstractDetachedCriteria.getSupersededJoinTypes()is the same new public API on 8.0.x as on 7.0.x (point 5 on #17067). -
The description names e7fbf6e as the change to review. b5fecc8 is on top of it, for James's first comment.
-
As a fix that changes a result, this needs a second reviewer (#17061).
|
@jdaugherty this and #16863 are yours to land first on Hibernate 7. They rewrite the same files as my consolidation (#16891): I am not changing those files on #16891, #16930 (an association block that is a branch of Nothing for you to do here. |
matrei
left a comment
There was a problem hiding this comment.
Reviewed again at 1cba001, with the Hibernate 7 probes of my second reviews of #17067 to #17074, against 8.0.x (fca95de) and the Hibernate 5 stack at #17073 (eba8ef9). Points 1 to 6 of my first review are fixed:
- With discriminator multi-tenancy,
deleteAllthrough a join table deletes the one case thatlistreturns. updateAllanddeleteAllapply the join type that a subquery requests, also in a junction, under a tenant and forteam ina subquery.Player.createCriteria().list { team { join('club', JoinType.INNER) } }returns the 6 players ofjoin('team.club', JoinType.INNER).- The order of
joinand the block of the association no longer decides the join type. A left join requested before or afterclub { order('name') }, or with thefetchargument, returns the 5 teams of the Hibernate 5 stack. - The bags hold their elements:
Team.where { members { name == 'a' } }.join('members', JoinType.LEFT).join('trophies').list()andTeam.list(sort: 'trophies.title', fetch: [members: 'join'])hold both members. Player.list(fetch: ['team.players': 'join'], max: 2)returns the 2 players, with the team's players fetched.
From my notes, the guide names the results that differ from Hibernate 5 on purpose (note 8), and the parent now counts the join of a sort by an association to a single instance (note 9). Apart from these and the points below, the probes give the same results here as at 6de9334. CI passed except for the coverage job, whose only failures are the DB2 rows, which couldn't pull icr.io/db2_community/db2 (#16929).
Needs a fix
1. A left join requested for a nested path no longer applies to a nested block, which works on 8.0.x.
Player.createCriteria().list { or { team { club { eq('name', 'Chelsea') } }; eq('name', 'Unattached Player') }; join('team.club', JoinType.LEFT) } |
8.0.x | This head | Hibernate 5 stack |
|---|---|---|---|
| players | 5, with the player whose team has no club | 4 | 5 |
The same holds with join('team.club', JoinType.LEFT) before the block. With list(fetch: ['team.club': JoinType.LEFT]), it's 4 here and on 8.0.x, and 5 with Hibernate 5. The where query, Player.where { team.club.name == 'Chelsea' || name == 'Unattached Player' }.join('team.club', JoinType.LEFT).list(), returns the 5 players here. The fix of point 3 seems to apply the type only to a block one level down.
2. count and totalCount don't count what the list returns for a right join through a path, and for a criteria sort by a collection. The description says that they count the instances that the list returns, "also for a collection, a collection of a basic type and a right join":
list |
count or totalCount |
|
|---|---|---|
new DetachedCriteria(Player).join('team.club', JoinType.RIGHT) |
8: the 6 players with a club and two null |
9 |
Team.createCriteria().list(max: 10, sort: 'players.name', fetch: [players: JoinType.LEFT]) { }, also with join('players', JoinType.LEFT) or order('players.name') |
7 teams | 9 |
Team.createCriteria().list(max: 10, sort: 'players.name') { } |
5 teams | 7 |
The second row counts the joined rows. The third leaves out the inner join of the sort, so it's the count of #16863 for a collection. The second row also differs from the Hibernate 5 stack, which returns the 5 teams with a player and the team with three players three times, the case of James's comment on #17070. On the right join: new DetachedCriteria(Team).join('club', JoinType.RIGHT) lists a null for each of two clubs that no team refers to, but with list(fetch: [players: JoinType.LEFT]) it lists one null.
3. Resolve the conflicts with 8.0.x. The skill entry conflicts with 8.0.x again, and so does #16863, so no check has run against the current 8.0.x.
Smaller points
- The follow-ups that the description names for #17070, a map of sort properties in a criteria query, and for #17073, a sort by the root alias, still fail here. I asked on those pull requests for an issue to track them.
Team.findAll(new Team(), [sort: …])still returnsnullhere and on 8.0.x, my note 11. On 9.0.x,Team.findAll(new Team())returnsnullwithout a sort too, andfind(new Team())as well, while an example with a property set works. So it's the empty example, a bug of its own.- The bag that
listfetches next to a sort by another collection is now loaded separately here. #17072 throws for the same call; I suggested the same approach there.
As a fix that changes a result, this needs a second approval under #17061.
…eries and of the subgraph fetches, and tell the rows of a Boolean ignoreCase from those of a String one by their names, with Hibernate 7
…ies, tell the rows of a Boolean ignoreCase from those of a String one by their names, and drop the note on the prints that the Hibernate 7 specification no longer makes, with Hibernate 5
…rnate 5 module on 8.0.x, and the value of 7.0.x in each of its rows, with Hibernate 5
…collection fetch and sort that count each owner once, of a fetch mode for the collection a criteria query sorts by and of a bulk write through a join table under a tenant, with the values that Hibernate 5 returns, with Hibernate 5
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. The null comparison on the identifier delete path no longer throws. A page of teams is still a page of child rows, a nested fetch can still drop a member, and a bulk delete can still remove a row that stopped matching. A nested bag on an entity graph is duplicated.
…ibernate 7 specification of the association join types measures, and the rows of a block with a join type that it adds to the fetch mode requested after a join type, with the values that Hibernate 5 returns and the Hibernate 7 value of each row that differs, with Hibernate 5
jdaugherty
left a comment
There was a problem hiding this comment.
Replies to the reviews at b7b5abf (@matrei 6202176135, @sbglasius 6202157869, @jamesfredley 6200388420 and 6201371543). The head is now 6eecdc6, which also merges 8.0.x (847e06d).
Each point was measured on 8.0.x (a592b38), at b7b5abf and with Hibernate 5 on 7.0.x (f3e134d).
A comparison with null in an update or a delete that selects the identifiers first (@matrei, @sbglasius, James's r4809770523): fixed in 9f64677 with the change @matrei tried in PredicateGenerator.convertValue. All 72 writes give 8.0.x's result, which is also what Hibernate 5 writes in the 69 it can run; its deleteAll of the or form fails on the foreign key of the tags table. 30 of the 72 rows fail at b7b5abf. The description says that a comparison with null matches nothing.
A scroll that fetches a longer path through a collection and sorts through its elements (@matrei, James's r4808968310 and r4809770516): with an inner or an untyped join, the collection is left to be read again and keeps all of its elements, as on 8.0.x and with Hibernate 5 (9ed40b3). With a left join, the scroll holds only the elements that the sort joins, which is what Hibernate 5 returns, so that stays, and the note, the skill and the description say so. scroll { join('members'); order('members.contract.name') } now leaves the collection to be read as well, as Hibernate 5 does, where 8.0.x fetched it with a1 only.
The total next to an alias of the bag that join fetches (@matrei, James's r4808968297): no code change. The total is 3 for the sort by the badge and 4 for the sort by the name, with Hibernate 5 as here, and 2 and 3 on 8.0.x. The list runs with Hibernate 5; only its count() fails, with a SQLGrammarException for the order by. The note, the skill and the description have the sentence that names the case.
Not changed:
- A sorted static
listthat pages through the rows of another collection (r4809770514): as on 8.0.x. - The read-only setting behind an instance the session holds (r4808968322): not reproduced, on 8.0.x, here or with Hibernate 5.
- A row that changes between the selection and the write (r4808968318, r4809770520): as with Hibernate 5.
Also in this push, from a local review of cd22c74: the selection of the identifiers projects the mapped identifier next to a property named id; ne with a null matches nothing in such a write; a nested collection loaded after a read-only query is read-only behind a held instance, and an immutable instance of the same batch stays read-only; join inside and, or and not of an association that only an alias joins fetches nothing; a name inside an association block is the property of the block, not an unused alias; an inner join below a right join of an alias keeps the rows of the right join; findWhere holds each element of a List mapped as a bag once; a fetchSize that is not positive takes the place of the hint also with a join type; and a bag of an entity graph is not repeated by the join of a sort.
Tests. Every call that a reviewer measured in these reviews has a row now (138 rows added for them in b640acb). On the merged head: :grails-data-hibernate7-core:test 8823 tests, 0 failures, 106 skipped; :grails-datamapping-core:test 1838 tests, 0 failures, 2 skipped; codeStyle passes. The same specifications are in the Hibernate 5 module now, at the same paths and with the same rows, asserting what Hibernate 5 returns on this branch and naming the Hibernate 7 value on each row that differs: 52 specifications, 3183 rows, 1529 equal and 1654 that differ, 520 of them calls that Hibernate 5 cannot run. :grails-data-hibernate5-core:test: 7628 tests, 0 failures, 464 skipped. Two are not mirrored because they need a MySQL and a PostgreSQL container that the Hibernate 5 module has no test dependency for (RequestedJoinSiblingTableSpec, RequestedJoinRingDeleteDialectSpec), and three test classes of the Hibernate 7 module.
This comment has been minimized.
This comment has been minimized.
…lso when it loads a bag after the query next to a sort by another collection and pages through the rows of that sort, as Hibernate 5 does, with Hibernate 7
… a bag next to a sort by another collection, which Hibernate 7 now lists as Hibernate 5 does, with Hibernate 5
…through an alias of a collection that it joins as Hibernate 5 pages and totals it, which this change already returns, in place of the pending feature of apache#17329
…t names, whose message the JVM words differently once it compiled the call, with Hibernate 5
…s a bag next to a sort by another bag in the chart of the criteria on a collection, with Hibernate 7
jdaugherty
left a comment
There was a problem hiding this comment.
Replies to @jamesfredley's review 6203474727, which was written at 6864237. The head is now 8bfd6af.
Since 6864237:
- Every specification that this pull request adds or changes for Hibernate 7 now also exists in the Hibernate 5 module, at the same path and with the same data, calls and rows, asserting what Hibernate 5 returns on this branch and naming the Hibernate 7 value on each row that differs: 52 specifications and 3183 rows, 1537 equal and 1646 that differ, 520 of them calls that Hibernate 5 cannot run. The Hibernate 5 module gets tests only. A disputed value can be read off the two rows.
- A static
listthat fetches a collection lists each instance of the rows of its page once, as Hibernate 5 does (8248fd0).Team.list(max: 2, sort: 'trophies.name', fetch: [members: 'join'])held A twice and now holds A once; the pages still go through the rows of the sort and the total counts them, as with Hibernate 5. - The feature for #17329 in
RequestedJoinPageTotalSpecexpected pages and a total that 8.0.x, this branch and Hibernate 5 all do not return. It now asserts the pages A, A, B with a total and a count of 3, which are the pages and the total of Hibernate 5, and passes.
:grails-data-hibernate7-core:test: 8823 tests, 0 failures, 105 skipped. :grails-data-hibernate5-core:test: 7628 tests, 0 failures, 464 skipped. codeStyle passes.
@matrei, the three points you held your approval for are answered in my review 6203506237: the comparison with null uses your change, the scroll with an inner or an untyped join leaves the collection to be read, and the note names the total next to join of the same collection.
…n to a single instance after the query as well when findWhere or findAllWhere sorts through the collection that its fetch argument loads after the query, so that the join of the sort does not repeat its elements, as with Hibernate 5 and on 8.0.x, with Hibernate 7
…names the clubs or the divisions of the league in a subgraph, next to a join type or a fetch mode of the members, with and without a sort by their names, with Hibernate 5
…s and sorts by the trophies without an offset, which lists team A once, as Hibernate 5 does, with Hibernate 7
…s and sorts by the trophies without an offset, with Hibernate 5
matrei
left a comment
There was a problem hiding this comment.
Twenty-fourth round, at 8bfd6af. Since my review at b7b5abf:
- 9f64677, 493e134, 9ed40b3, 04554a9, da84580 and 8248fd0 change the Hibernate 7 code, and 7aa5c91 and the commits after it change the note, the skill and the description.
- 6864237 merges 8.0.x (847e06d).
- The other commits add rows to the Hibernate 7 specifications, and add the same specifications to the Hibernate 5 module.
You replied in 6203506237 and 6204380798, and in the threads.
Following #17274, each point says whether it is a change from 8.0.x that this pull request makes, a defect of the code it adds, or a case that behaves the same on 8.0.x. I compared with 8.0.x at 847e06d, the commit that the merge brings in. The three points of my last review are fixed. I hold my approval for the two points under "Still open". Each is a change from 8.0.x that this pull request makes. The second only needs a sentence in the note and the description.
Fixed
- A comparison with
nullin an update or a delete that selects the identifiers first (my review 6202176135, James's comment r4809770523, sbglasius's review 6202157869): at this head, my 72 writes give 8.0.x's result. So do my 56 reads and writes withne,inListandisNullwith anull, except that the inner join leaves out the entries without a tag, as before. - A
scrollthat fetches a longer path through a collection and sorts through its elements (James's comments r4808968310 and r4809770516):- With
JoinType.INNERand withjoin('members.badge'), the members of A are left to be read and hold a1 and a2, as on 8.0.x. - With
JoinType.LEFT, the scroll still holds a1 only. The note, the skill and the description now say so, which is one of the two ways my review offered. scroll { join('members'); order('members.contract.name') }now leaves the members to be read as well, where 8.0.x held a1 only. The note says that too.
- With
- The total next to an alias of the bag that
joinfetches (James's comment r4808968297): the note, the skill and the description name the case. My rows give 3 here and 2 on 8.0.x, as at b7b5abf.
Still open
-
A bag in a subgraph of the entity graph of a sorted
findAllWhere(James's comment r4811304059): you are measuring it (r4812014943), and these are my values. In my probes, team A has the members a1 and a2, aCollection, and the league L, whose clubs k1 and k2 are aCollectionas well. The graph isgraph.addSubgraph('league').addAttributeNodes('clubs').Team.findAllWhere([name: 'A'], [fetch: [members: JoinType.LEFT], sort: 'members.name', 'jakarta.persistence.fetchgraph': graph])loads the clubs as[k1, k1, k2, k2]here. The same holds withjakarta.persistence.loadgraph.- On 8.0.x, the clubs are left to be read and hold k1 and k2.
- At b7b5abf it was the same as here. 493e134 loads only a bag at the top of the graph after the query (
graphBag.indexOf('.') < 0), so it doesn't reach a bag of a subgraph. - Without the sort, or with
sort: 'name', the clubs hold k1 and k2 here.findWhereholds k1 and k2 as well. A graph that names the trophies, aSet, holds t1 and t2 once.
One of these would do:
- Hand no entity graph to Hibernate when the sort goes through a collection that the query loads after it, as 8.0.x and Hibernate 5 do.
RequestedJoinGraphSortSpecwould then expect the coaches to be left to be read. - Load a bag of a subgraph after the query as well.
Following #17274, I'd prefer the first. It removes what 493e134 adds rather than adding to it, and it gives 8.0.x's result.
-
What 8.0.0 returned for a static
listwith a join type infetchnext to a sort by another collection (8248fd0): in my probes, A has the trophies t1 and t2, B has t3, and C has none.Team.list(max: 2, offset: n, sort: 'trophies.name', fetch: [members: JoinType.LEFT])gives the pages[A], then[B], here, with a total of 3. On 8.0.x, and at b7b5abf, the pages are[A, A], then[B].- Without
max, the list holds A and B here, and A, A and B on 8.0.x. - The same holds with
JoinType.INNER, and withfetch: ['league.clubs': JoinType.LEFT].
Your reply r4812014366 gives the same pages for 8.0.x. The note and the description give 8.0.0's result for
fetch: [members: 'join']only: "8.0.0 paged through the instances there and held each element of the bag once for each element of the sorted collection". With a join type, 8.0.0 listed the instance once for each row of the sort. A sentence that says so would do. I think listing each instance once is right: James asked for it in r4811304055, and Hibernate 5 does it.
Optional
These are not conditions, following #17274.
- The Hibernate 5 specifications: the 52 specifications, about 16,000 lines, don't test code that this pull request changes, since it changes no main source of the Hibernate 5 module. They add a lot to review here, and I'd move them to a pull request of their own.
- They pin what Hibernate 5 returns today, a defect included.
RequestedJoinTimeoutSpecexpects a staticlistwith atimeoutto fail with anAbstractMethodErroron 8.0.x. A fix of that defect would then fail the specification. - I found no issue for it. An issue, and a
@PendingFeaturethat names it, would record it instead. - The assertion on the message of that error failed the three Hibernate 5 jobs at 6eecdc6. e367a8a compares the method that the message names, and the three Hibernate 5 jobs pass at this head.
- They pin what Hibernate 5 returns today, a defect included.
- #17329: it asks that the pages, their total and
countagree. They do here:RequestedJoinPageTotalSpecnow asserts the pages A, A and B with a total and acountof 3 (4d0fc2d), where 8.0.x counts 2. The description could say that this pull request fixes #17329, or the issue could be closed with that result.
Not conditions
- A sorted static
listthat pages through the rows of another collection (James's comment r4811304055): the pages go through the rows of the sort, as on 8.0.x. That each instance is now listed once is the second point under "Still open". - A row that changes between the selection and the write (James's comment r4811304058): as in my last review. Selecting the identifiers first is how the description says these writes apply a join type.
fetchvalues that fetch nothing: a staticlistwithfetch: [members: 'select', league: JoinType.LEFT]orfetch: [members: 'lazy', league: JoinType.LEFT], sorted bytrophies.name, holds A twice, as on 8.0.x. It doesn't count as fetching a collection.
What I ran
- The Hibernate 7 tests:
:grails-data-hibernate7-core:testran locally at this head: 8823 tests, no failures, 100 skipped. - CI at this head: 85 checks pass and none fail. Four are still running, among them one Hibernate 7 job.
- My earlier probe sets: the 155 calls of my earlier sets ran at this head, and on 8.0.x at 847e06d, where they give the same as at a592b38.
- New probes:
- 30 calls on static lists with a fetch next to a sort, on
findWhere,findAllWhere,get,findByandDetachedCriteria.getwith two collections, and on entity graphs with a sortedfindAllWhere. They ran on 8.0.x, here, and at b7b5abf. - 5 calls with
fetchvalues that fetch nothing, on 8.0.x and here.
- 30 calls on static lists with a fetch next to a sort, on
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A page of teams is still a page of child rows, a nested fetch can still drop a member, a bulk delete can still remove a row that stopped matching, and a nested bag on an entity graph is still duplicated.
…s through a collection that the query loads after it, as Hibernate 5 and 8.0.x apply none there, in place of loading the bags of the graph after the query, so that the associations of the graph are left to be read, with Hibernate 7
…re and findAllWhere with an entity graph next to a join type, whose graph Hibernate 7 now leaves to be read as Hibernate 5 does, with Hibernate 5
…tch argument next to a sort by another collection, which listed the instance once for each row of the sort, in the note and the skill
…g features of apache#17340, in place of the AbstractMethodError that the Hibernate 5 module raises on 8.0.x, with Hibernate 5
jdaugherty
left a comment
There was a problem hiding this comment.
Replies to @matrei's review 6204424592 (at 8bfd6af) and @jamesfredley's review 6204515714 (at b64060b). The head is now 670c05c.
A bag in a subgraph of the entity graph of a sorted findAllWhere (@matrei's first open point, James's r4811304059): done the first way that you offered, in 554915f. A findWhere or findAllWhere that sorts through a collection that it loads after the query hands no entity graph to Hibernate, as 8.0.x and Hibernate 5 apply none there. That removes what 493e134 added, and what 67004f5 had added for the subgraph after your review; the two Java files are 45 lines shorter than at b64060b. RequestedJoinGraphSortSpec expects the coaches to be left to be read, and the 16 sorted rows with a join type of RequestedJoinSubgraphFetchSpec expect only the members to be loaded and the league to be left to be read. Those 18 rows give 8.0.x's result, in what they hold and in what is loaded; all 18 fail at b64060b. Unsorted calls and a sort that does not go through such a collection keep the graph, as before.
What 8.0.0 returned for a static list with a join type in fetch next to a sort by another collection (your second open point): the note, the skill and the description now say that with a join type 8.0.x listed the instance once for each row of the sort, with the pages [A, A] and [B] and A, A and B without max, and that it is now listed once (a0151cc).
Your optional points:
- The Hibernate 5 specifications stay in this pull request. They pin what Hibernate 5 returns for the same data and calls, which is what each Hibernate 7 value here is argued against, so they belong next to the rows they are compared with.
- The static
listwith atimeoutin the Hibernate 5 module is #17340 now. The six rows of the Hibernate 5RequestedJoinTimeoutSpecno longer assert theAbstractMethodError; they are two pending features with that issue, which expect the timeout to reach the statement, as on 7.0.x and with Hibernate 7 (670c05c). - The description says
Closes #17329.
Tests. :grails-data-hibernate7-core:test: 8889 tests, 0 failures, 105 skipped. :grails-data-hibernate5-core:test: 7694 tests, 0 failures, 470 skipped, six more than before for #17340. codeStyle passes. The Hibernate 5 module still has test changes only.
… subgraph of the league targets a subclass and names a bag of the subclass, next to a join type of the members, with and without a sort by their names, which hold each element of the bag once as on 8.0.x and as Hibernate 5 does, with Hibernate 7
… subgraph of the league targets a subclass and names a bag of the subclass, next to a join type of the members, with and without a sort by their names, and the failure of the subgraph forms of Jakarta Persistence 3.2, with Hibernate 5
…ere fetches with a join type after the query as well when the entity graph names a bag in a subgraph of the root graph that targets a subclass, where the two bags failed with a MultipleBagFetchException, so that a sorted call hands no graph to Hibernate and holds each element once as on 8.0.x, and hold the unsorted calls, which repeat the instance or drop an element as the graph alone does, in a pending feature of apache#17328, with Hibernate 7
… root graph has a subgraph that targets a subclass and names a bag of the subclass, next to a join type of the members, with and without a sort by their names, and the failure of building that subgraph, with Hibernate 5
Description
The Hibernate 7 counterpart of the requested join type parts of the split of #16853: #17067, #17068 and #17069, which reached 8.0.x with the merge-up of 7.0.x, and the open #17071. As agreed on dev@, Hibernate 7 gets the same rule and spec on 8.0.x, so that the two modules do not return different rows for the same query. Relates to #15589.
Stacked on #16863, and merged together with it. This pull request targets the branch of #16863, so its diff shows only the requested join types. #16863 merges first, and this pull request then merges into 8.0.x. A static
listof #16863 that sorts by one collection and fetches a bag holds the bag's elements once for each element of the sorted collection, and the loading of such a bag after the query, here, fixes that.A where query, a detached criteria, a dynamic finder or a criteria query can request the type of the join of an association, with the
fetchargument, withjoin(association, JoinType)or, for parameter-query data-service methods, with@Join.type. Hibernate 7 applied it to the list of a query that requests it for an association of the queried class, and otherwise ignored it. A join type other than a left join is now applied whether or not anything else in the query uses the association.Results that change
count()and thetotalCountof a paged list count the instances that the list returns for a requested join type, also for a collection, a collection of a basic type and a right join, whose unmatchednullrows are counted. A list that fetches a collection, also one behind an association to a single instance such asfetch: ['team.players': JoinType.LEFT], returns each instance once, and its total counts the instances. A list that fetches a bag next to a sort by another collection pages through and counts the rows of the sort, as the same list without the fetch does and as Hibernate 5 does on 7.0.x; a staticlistlists each instance of those rows once, as with Hibernate 5, so a page of two rows can hold one instance, as inTeam.list(max: 2, sort: 'trophies.name', fetch: [members: 'join']). On 8.0.x such a list pages through the instances and holds each element of the bag once for each element of the sorted collection. With a join type infetch, as inTeam.list(max: 2, sort: 'trophies.name', fetch: [members: JoinType.LEFT]), 8.0.x lists the instance once for each row of the sort instead: with a team A that has two trophies and a team B that has one, the pages are[A, A]and[B], and the list withoutmaxholds A, A and B; this change lists each instance once. When the criteria of the query join a collection, with an association block, an alias or a criterion on a property of a collection,count()and the total of a page count the rows of those joins instead, which the pages go through, as the page totals of 8.0.0 do and as Hibernate 5 does where it runs the query, also when the list fetches a collection. Next tojoinof the same collection, as injoin('members'); createAlias('members', 'm', 1); order('m.badge.name'), they count the rows of the alias as well, as the total of a page does with Hibernate 5, where 8.0.x counted fewer (2 where this gives 3). The 8.0.x branch counts the instances when such a query sorts by a collection, as inSquad.createCriteria().list(sort: 'members.name', max: 10) { coaches { like('name', '%') }; like('members.name', '%') }, where it counts 2 and its pages go through 5 rows, so that total differs from 8.0.x here; a sort by a collection that the list fetches and that the criteria do not join keeps the count of the instances, unless the list loads that bag after the query, where the total counts the rows that its pages go through. A sort by a collection that the query does not fetch counts the rows of its join, as with Hibernate 5. A count of a property, a distinct count or a count next to another projection counts the rows of the criteria, as on 8.0.x; GORM for Hibernate 5: count and totalCount of a where query that requests a join of a collection and sorts by it count a row for each element #17178 tracks where queries that list such an instance once.fetch: ['author.publisher': JoinType.LEFT, author: JoinType.INNER]leaves out the books without an author. A path that ends in or passes through a collection restricts the query with a correlated subquery, so each instance is returned and counted once and a fetched collection keeps all of its elements. A path through an embedded component, such asdetails.author, is left alone, as with Hibernate 5. Below a right join, a deeper join type that restricts through a collection, as in.join('author', JoinType.RIGHT).join('author.publisher.tags', JoinType.INNER), lists no row without an instance, as with Hibernate 5; 8.0.x listed thenullrow.updateAllanddeleteAllapply it, so they leave out the instances that the join type leaves out oflist. A sort is not applied to them, as with Hibernate 5, so an instance that only the join of a sort leaves out oflistis still changed. They select the identifiers with the same joins and tenant filters as a select query, also for a join type requested inside a subquery and for a delete through a join table. They write those identifiers in batches of 500, each a statement of its own, so a database that checks a foreign key when a statement ends, such as PostgreSQL, refuses adeleteAllwith a join type requested through a join table when more than 500 of the instances refer to each other in a ring; 8.0.x ignores the join type and deletes them in one statement (Hibernate 7: deleteAll with a requested join through a join table refuses a ring of more than 500 instances on PostgreSQL #17334). Without the join type they are deleted as before. On MySQL and on MariaDB before 10.3, where a write cannot select from the table that it modifies, a join type to a class that shares the table of the queried class selects the identifiers first, as with Hibernate 5, and a path back to the queried class or through a collection of a basic type is rejected. An update or a delete that selects the identifiers first fails with anUnsupportedOperationExceptionfor an entity with a composite identifier, which it cannot write by identifier (Hibernate 7: updateAll and deleteAll with a join type to a class that shares the table cannot write an entity with a composite identifier on MySQL #17338 for the shared table on MySQL). The selection of the identifiers selects the mapped identifier, also for an entity with another property namedid, and compares as the statement does, also inside a subquery: a not-equal does not match anull, a comparison withnull, such aseq,ne,gtorbetweenwith anulloridEq(null), and anullin the list ofinListmatch nothing and stay unknown undernot, and a subquery without a projection selects its instances.list,findWhere,findAllWhereand the example queries apply a join type in theirfetchargument.listkeeps the default sort of the mapping andmax: 0when it does, appliesreadOnly,flushMode,fetchSizeandtimeoutand lists an instance once for each element of a collection that it sorts by, as without a join type, and an empty map still returnsnull. Alistwithmax: 0and a join type returns an empty page with its total, also for asortthat names no property, as with Hibernate 5, where 8.0.x rejected that sort. A sortedfindWhereorfindAllWherehands the driver afetchSizethat is not positive also next to a positiveorg.hibernate.fetchSizehint, with and without a join type, as Hibernate 5 does, where 8.0.x used the hint.fetchargument of a criteria query'slistis applied; it was ignored, for a fetch mode as well. A join type in it does not replace one given to an association block or tocreateAliasof the queried class, as inclub(0) { }orcreateAlias('club', 'c', 0).join('author')andselect('author')are fetch modes at the top level of the query, as in a where query.joinapplied an inner join, andselectreturned the authors instead of the instances.fetchMode('author', FetchMode.JOIN)fetches the association with a left join as well; it fetched nothing, so a sort through a collection fetched that way listed an instance once for each element. Any other fetch mode, such asFetchMode.DEFAULTorFetchMode.SELECT, still fetches nothing. Inside an association block,selectstill projects, as on 8.0.x (Hibernate 7: select inside an association block resolves against the queried class #17201).selectof a to-many property that is mapped to a column, as withtype: 'serializable', returns the instances as well, as with Hibernate 5; 8.0.x returned the serialized collections.selectof a path through another association, such asselect('team.club'), and'select'or'lazy'for such a path in thefetchargument of a where query or a dynamic finder are fetch modes too, so the query returns its players, as with Hibernate 5; on 8.0.x they returned the clubs, and a where query'sfetch: [team: 'select']returned the teams.createAliaswithout a join type uses the join type that the query requests for the association, as an association block does, sojoin('club', JoinType.LEFT)orfetch: [club: JoinType.LEFT]together withcreateAlias('club', 'c')keeps the teams without a club, as with Hibernate 5 (Keep a join type that a fetch mode replaced for the joins of a criteria query #17192, Sort a criteria query by a property of an association #17070). It always made an inner join;createAlias('club', 'c', 0)still does.joinorselect; outside a junction, an explicitly typed block keeps its own type, and inside one the type requested for its path takes its place, as at the root. In a criteria query, a join requested inside an association block is relative to the block, as with Hibernate 5; a where query or a detached criteria leaves alone a join type requested inside one of its blocks, as on 8.0.x and with Hibernate 5. Insideand,orandnot,joinwith an inner join of a to-one association leaves out the instances without one and fetches nothing, andjoinwithout a join type replaces a join type requested before it without fetching an association that the query left lazy, both as on 8.0.x. A default block of an association after ajoinof it insideand,orornotleaves the collection to be read, and a sorted page goes through the rows of the join, as with Hibernate 5; on 8.0.x the block fetched the collection and the page went through the instances.SemanticException.listfetches a nested collection together with its owner, as inPlayer.list(fetch: ['team.players': 'join'], max: 2). A single requested bag that another collection join would multiply, and a collection fetched next to a to-one right join that the query requests, or that a laterjoin,selectorfetchModereplaced while criteria, an alias or an order still join through it, are loaded after the query, as with Hibernate 5, so a bag keeps its elements once and two unmatched rows stay twonulls, unless the query also sorts by a collection, as Hibernate then makes them one; a sort through such a collection joins it with the left join that the fetch would have made; this can add a query per returned instance and collection. The restriction on fetching two bags together remains, also for a path through two bags, such asfetch: ['children.leaves': JoinType.INNER]. A bag that is loaded after a read-only query is loaded read-only, as when the query fetches it, also behind an association that the query fetched or an instance that the session held; what Hibernate loads in a batch beside it keeps the setting of the session, an immutable instance stays read-only, and the load uses the cache mode of the query. AListthat Hibernate maps as a bag, as with@Bag, thatfindAllWherefetches together with another collection without an entity graph is fetched with it, so it holds each element once for each element of the other collection, as with Hibernate 5;findWhereloads such a bag after its query, so it holds each element once, as with Hibernate 5, whosefindWherefetches nothing. An alias of an association to a single instance that a later alias orjoinof the same association declares with another join type still makes its right join, and the two unmatched rows of that join stay two rows as well. A criteria list also loads a bag that itsfetchargument orfetchModefetches after the query when its criteria join the same bag with an alias, a property of the bag or a block insideand,orornot, so the bag holds each element once; afterjoinof the bag it holds each element once for each row of that join, as on 8.0.x. A block insideand,orornotfetches nothing, so a bag that the query fetches next to it and to a block of another bag is loaded after the query. A query that asks for writable instances in a read-only session loads writable elements into a bag that it loads after the query. A join type requested before an alias of the same association with another join type lists and counts the rows that 8.0.x does. A staticlistthat runs as a criteria query fetches a path for the fetch modes'join'and'eager'as they are written, as the same list without a sort does, and not for a GString.findWhereandfindAllWherewith a join type in thefetchargument still hand an entity graph hint to Hibernate, unless they sort through a collection that they load after the query, see below. A staticlistwith a join type in itsfetchargument readsignoreCaseas the HQL oflistdoes. A collection that a query fetches is also loaded after the query when the query sorts by an association of its elements, so it keeps the elements without that association, which the inner join of the sort left out. On 8.0.x these held only the elements with the association:Team.createCriteria().list { join('players'); order('players.contract.name') }, also with a join type and thesortargument,new DetachedCriteria(Team).join('players').sort('players.contract.name').list()and the where query,Team.findAllByNameLike('t%', [fetch: [players: 'join'], sort: 'players.contract.name']), andTeam.list(fetch: [players: 'join'], sort: 'players.contract.name')when the players are a bag. With a join type, as inTeam.list(sort: 'players.contract.name', fetch: [players: JoinType.LEFT]), 8.0.x left the collection to be read. The instances that the list returns and the total, which counts them, do not change, andmaxandoffsetpage through those instances, taken from all the rows of the query once they are read, as Hibernate takes them when the query fetches the collection; the offset of a finder that returns one instance, asfindWhere, goes through them as well. The fetch of a longer path through the collection, asfetch: ['members.badge': JoinType.LEFT]next to a sort bymembers.contract.name, is loaded after the query in the same way. Ascrollstill fetches a collection that a left join requests with the query, also for a longer path through it, so it holds only the elements that the sort joins, as with Hibernate 5, where 8.0.x left the collection of a longer path to be read; a collection thatjoinrequests without a join type or with an inner join is left to be read, as with Hibernate 5, where 8.0.x fetched it forjoin('players'). A collection that thefetchargument offindWhereorfindAllWherefetches with a join type is loaded after the query as well when an entity graph hint, given as a graph or as text, names another collection, also in a subgraph, and one of the two is a bag, also aListthat Hibernate maps as a bag, where the two would be fetched together and fail with aMultipleBagFetchException; 8.0.x ignored the join type and loaded the bag of the graph only. When such a call also sorts through a collection that it loads after the query, as through that collection withsort: 'members.name', it hands no entity graph to Hibernate, as Hibernate 5 and 8.0.x apply none there: the associations that the graph names are left to be read, and each element of a bag that the graph names is held once.list,findWhereandfindAllWhereon a named connection keep it when they run as a criteria query, including their paged totals, also while a tenant is bound and for the example finders with a join type. A sortedfindWhereorfindAllWherewithout a join type does not yet (Hibernate 7: a sorted findWhere or findAllWhere on a named connection reads the connection of the bound tenant #17336), and ignores atimeoutof zero (Hibernate 7: a sorted findWhere or findAllWhere ignores timeout: 0 and runs with the session's query timeout #17337); with a join type the zero reaches the statement.How to get the old result: remove the join type that the query requests, or request
JoinType.LEFT. For a criteria query that relied onjoin('author')leaving out instances, requestjoin('author', JoinType.INNER). An application that relied on a fetched collection holding only the elements with the association of the sort can filter it, as inteam.players.findAll { it.contract }.Setting: none. A requested join type that is ignored contradicts the call, which the rule from the dev@ thread sends to the oldest branch that has the bug, and so does a fetched collection that lacks some of its elements, which contradicts the fetch. Two reviewers.
Differences from the Hibernate 5 spec
AssociationJoinTypeSpecis the specification of the Hibernate 5 change, ported. On 8.0.x 79 of its 140 cases failed. Five things differ from the Hibernate 5 spec:leftJoinAssociationSort.new DetachedCriteria(Player).join('team.players', JoinType.LEFT).list(max: 10, sort: 'team.players.name'), pages through the instances and counts them, ascount()of the same query does. Hibernate 5 on 7.0.x and at Apply a join type in the fetch argument of list and the example queries #17071 pages through the rows of the join and counts them, so a page can hold fewer instances thanmaxand the total counts more rows than there are instances. 8.0.x pages through the rows and counts the instances.fetchargument of a criteria query'slistdoes not replace the join type that a block gives, also inside a junction, as inPlayer.createCriteria().list(fetch: ['team.club': JoinType.LEFT]) { or { team { club(0) { ... } }; eq('name', 'u1') } }, and a typed block outside a junction keeps its join type over a request for its association. Both are as on 8.0.x; Hibernate 5 takes the request.new DetachedCriteria(Team, 't').eq('t.name', ...)) are left out. Hibernate 7 does not resolve such a path; Hibernate 7: resolve the root alias in detached-criteria sorts and restrictions #17167 tracks it.Not changed here
findByTitle, still ignore the type of@Join: their generated fetch argument requests a fetch mode only.inList('id', subquery)has an association block in the subquery throwsJoins cannot be used in a DELETE or UPDATE operation, and a where query that restricts by one collection and fetches a bag repeats the bag's elements. Both happen on 8.0.x and with Hibernate 5, with or without a join type.listthat fetches aSetor aListwith a fetch mode and sorts by an association of its elements, as inTeam.list(sort: 'players.contract.name', fetch: [players: 'join']), runs as HQL and still holds only the elements that have that association. With a bag it runs as a criteria query and holds all of them, see "Fetching collections". A staticlisthands no entity graph hint to Hibernate, and a graph that itself names two bags fails with aMultipleBagFetchException. These are as on 8.0.x.findAllwith an example that sets no property by GORM for Hibernate 7: find and findAll with an example that sets no property return null #17169.Implementation
JpaCriteriaQueryCreator.applyRequestedJoinscollects the requested fetches and join types, joins and fetches to-one chains, adds theexistsrestriction for a path through a collection, and records the bag and right-join fetches that the list loads after the query. The count of an entity list joins the same paths without fetching them, so that a sort reads the same joins.HibernateSessionbuilds the bulk restriction from the same paths.HibernateGormStaticApirunslist,findWhereandfindAllWhereas aDetachedCriteriawhenfetchholds aJoinType.AbstractDetachedCriteria.getSupersededJoinTypes()ingrails-datamapping-corecame to 8.0.x with the merge-up of #17067 and #17192. Hibernate 7'sJoinPlannerreads it, so criteria joins keep their requested type when a later fetch mode replaces it.Documentation
The Grails 8.0.1 section of the upgrade notes has a note on requested join types, and the upgrade skill has the same entry. The note on a sort by a collection says which queries return and count an instance once.
Tests
AssociationJoinTypeSpeccovers each query API, the counts and totals, nested paths, paths through an embedded component that are left alone, bulk operations, subqueries, right joins and deferred fetches.RequestedJoinConnectionSpeccovers named connections,PartitionedMultiTenancyFilterSpecthe tenant filter of a bulk operation,CriteriaMethodInvokerSpecthefetchargument of a criteria query, andJpaCriteriaQueryCreatorSpecandJpaProjectionTranslatorSpecthe joins and the row count of a query.RequestedJoinJunctionSpeccoversjoininsideand,orandnot,ignoreCaseof a staticlistand the sort by an association of a fetched collection's elements, andRequestedJoinSortedFetchSpecthe lists that fetch a collection and sort by another collection or by the fetched one, with their pages, counts and totals.RequestedJoinBagFetchSpeccovers the sort by an association of the elements of a fetched bag and of a fetched set, and an entity graph that names a collection next to a join type of another, andRequestedJoinSubgraphFetchSpeca graph that names one in a subgraph, also next to a sort by the names of the fetched members.RequestedJoinSortedPageSpeccovers the pages and totals of these sorted lists, a fetch mode inside an association block next to an inner join insideand, and a direction of the sort given as a GString, andRequestedJoinPagedFinderSpecthe offset of a finder that returns one instance, a page with the largestmax, and asortargument of a staticlistthat is neither aStringnor aMap. Each measured call of these five specs is a row of awhere:block.RequestedJoinGraphHintSpec,RequestedJoinScalarCollectionSpec,RequestedJoinStateSpec,RequestedJoinPageTotalSpecandRequestedJoinBulkIdentifierSpeccover an entity graph given as text or naming a set, a to-many property mapped to a column, several requests for one association and a reused builder, the totals next to criteria on a collection and a right join, a cursor, and the identifiers of an update or a delete.RequestedJoinCaseAndPageSpeccovers the order of a staticlistwithout regard to case and the pages next to criteria on the fetched collection, with each call next to its result, andRequestedJoinOrderAndSubquerySpeca bulk write whose subquery requests a join of a to-many property mapped to a column, a staticlistwith anorderand nosort, and the pages and totals of a criteria list that joins a collection next to criteria on it or on another one.RequestedJoinHintAndListenerSpeccovers a query listener that changes the result of the selection of an update or a delete by identifiers, and hints that are not entity graphs.RequestedJoinTenantConnectionSpec,RequestedJoinBulkPredicateSpec,RequestedJoinFlushHintSpec,RequestedJoinGraphFormSpec,RequestedJoinAliasPlanSpec,RequestedJoinOrderOfJoinsSpec,RequestedJoinPrefixCountSpec,RequestedJoinJunctionBlockSpec,RequestedJoinCachedCollectionSpec,RequestedJoinSiblingTableSpec,RequestedJoinEmbeddedFetchSpecandRequestedJoinRightOwnerCollectionSpeccover the connection of a staticlistwhile a tenant is bound,nein an update or a delete by identifiers, the flush mode hint, the forms of an entity graph hint, the joins of aliases and of right joins declared in either order, the count of a nested fetch, a block inside a junction, a cached collection, a table of a sibling class on MySQL, a fetch through an embedded component and an inner join of a collection below a right join of its owner.RequestedJoinFetchSizeAndCursorSpeccovers a fetch size that is not positive and the equality of a cursor, andRequestedJoinRingDeleteDialectSpecthe delete of instances that refer to each other in a ring on PostgreSQL. The cases that fail in the same way on 8.0.x are pending features: #17328, #17332 and #17333.RequestedJoinPageTotalSpecasserts that the pages of a criteria query sorted through an alias of a collection that it joins, their total andcountagree, as #17329 asks: the pages and the total are those of Hibernate 5, andcountcounts the same three rows. Closes #17329. The ring of more than 500 instances, which 8.0.x deletes because it ignores the join type, is a pending feature as well: #17334.RequestedJoinBasicAliasSpec,RequestedJoinDeferredLoadSpec,RequestedJoinListBagGraphSpec,RequestedJoinPageTotalFlushSpecandRequestedJoinTimeoutSpeccover an unused alias of a collection of a basic type, the read-only setting and the cache mode of a collection loaded after the query, aListmapped as a bag next to an entity graph, the flush before the total of a static list page, and the timeout and the fetch size that reach the statement. The cases found on the way that this change leaves alone are pending features with their issue: #17335, #17336, #17337, #17338 and #16815, and in the Hibernate 5 module #17340.Each of these specifications also exists in the Hibernate 5 module at the same path, with the same entities, data, calls and rows, asserting what Hibernate 5 returns on this branch, with the Hibernate 7 value in a comment on each row that differs: 52 specifications and 3345 rows (520 of those are calls that Hibernate 5 cannot run). Not mirrored are
RequestedJoinSiblingTableSpecandRequestedJoinRingDeleteDialectSpec, which need a MySQL and a PostgreSQL container that the Hibernate 5 module has no test dependency for, andJpaCriteriaQueryCreatorSpec,JpaProjectionTranslatorSpecandCriteriaMethodInvokerSpec, which test classes of the Hibernate 7 module.:grails-data-hibernate5-core:testruns 7790 tests with 0 failures and 470 skipped.Contributor Checklist
Please review the following checklist before submitting your pull request. Pull requests that do not meet these requirements may be closed without review.
Issue and Scope
7.0.x): Bug fixes only. No new features or API changes.7.1.x): New features are welcome, but breaking existing APIs must be avoided.8.0.x): Reserved for major changes. Breaking API changes are permitted.Code Quality
./gradlew build --rerun-tasks../gradlew codeStyleand resolved any violations. See Code Style for details.Licensing and Attribution
Documentation