Repository navigation
fix(hibernate5): query arguments reach where queries and dynamic finders - #17078
borinquenkid wants to merge 6 commits into
Conversation
readOnly, fetchSize, timeout and flushMode are documented for findAll(Map, Closure), the dynamic finders and where queries, but the Hibernate 5 HibernateQuery did not implement QueryArgumentsAware, the hook both callers use, so they were dropped. No new extension point is added. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A page honors a manual flush. The count of that page still flushes.
… mode and the timeout of the query arguments A where query listed with max and a flushMode of MANUAL did not flush for its page, but reading its totalCount ran a copy of the query that had lost the setting, so the count flushed the pending change. The query remembers the flush mode and the timeout it applied from the arguments and gives them to the copy. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
@jamesfredley: the count behind the total of a page keeps the flush mode now. The query remembers the |
…nt, and the query arguments are pinned on every entry point A flushMode such as 'BOGUS' failed with the enum's own message, which does not name the argument, where a bad fetchSize or timeout does. CriteriaQueryArgumentsSpec now runs readOnly and flushMode on every entry point (where list, find, findAll with a closure, the finders, the paged forms), and a bad or null argument on each of them. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A timeout of half a second is stored as no timeout.
|
@jamesfredley: before asking for another look, I ran each argument on each entry point, so the neighbours of the manual-flush case are in one place. |
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A timeout of half a second is still stored as no timeout.
…nt range is refused, not cut Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
@jamesfredley: Before asking for another look, I tried 18 values (whole numbers as int, long, double, decimal and text, padded text, fractions as double, float, decimal and text, empty and non-numeric text, a long and a decimal past the largest int, NaN and infinity) for both arguments on four entry points: the where list, |
✅ All tests passed ✅🏷️ Commit: 13ddecf Learn more about TestLens at testlens.app/docs. |
…s not been staged again Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
@matrei: the notes are back under |
…nd the timeout of the query arguments Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
@jamesfredley: I ran every query setting (flush mode, lock, cache, read-only) through every paged route, to find the cases around the one you found on where queries. One more was left: |
jamesfredley
left a comment
There was a problem hiding this comment.
The items this review found have been addressed. A timeout that is not a whole number is refused, and the count keeps the flush mode.
Hibernate 5 part of #16823 (item 2 of matrei's review), on 7.0.x so it merges up.
Part of #16808
The bug
findAll.adoclistsreadOnly,fetchSize,timeoutandflushModeforfindAll(Map queryParams, Closure whereCriteria), andfindAllBy.adoclists them as metaParams of the dynamic finders. With Hibernate 5 they are ignored for both and forwherequeries:DynamicFinderandDetachedCriteriahand the arguments only to a query that implementsQueryArgumentsAware, and the Hibernate 5HibernateQuerydid not.list(args)andcreateCriteria().list(args)already applied them.The change
HibernateQueryimplementsQueryArgumentsAware, the hook both callers already use, so no extension point is added.setArgumentssetsfetchSize,timeout,readOnlyandflushModeon the Hibernate criteria and leaves the other arguments (max,sort, ...) to the caller. AfetchSizeortimeoutthat is not a whole number throws anIllegalArgumentExceptionnaming the argument. No public class or method is added beyond that interface method.What changes for applications
Arguments that were ignored now apply. The upgrade note is in the new Grails 7.0.19 section and says how to keep the earlier result (remove the argument). This changes a result, so it needs two reviewers. The Hibernate 7 part is #17077 (8.0.x).
Tests
CriteriaQueryArgumentsSpec(10 features):readOnlythroughwhere.list,findAll(args) { }and a dynamic finder (true and false), a single resultfind,flushModeMANUAL against ALWAYS, and the whole number check. WithoutsetArguments6 of the 10 fail. The fullgrails-data-hibernate5-coresuite passes.https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL