Skip to content

refactor(hibernate7): split HqlQueryContext into QueryParameters and QuerySettings - #16800

Merged
borinquenkid merged 2 commits into
8.0.xfrom
refactor/hql-query-context-split-8.0.x
Oct 30, 2026
Merged

borinquenkid merged 2 commits into
8.0.xfrom
refactor/hql-query-context-split-8.0.x

Conversation

@borinquenkid

@borinquenkid borinquenkid commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #16616.

Summary

Extracts QueryParameters and QuerySettings from HqlQueryContext in grails-data-hibernate7, completing the decoupling proposed in #16616 following the introduction of HqlText in #16735:

  1. QueryParameters:

    • Encapsulates named and positional parameters as an immutable value object with defensive copying.
    • Handles GString expansion for both named parameters (:p0, :p1) and positional parameters (?1, ?2 or native ?).
    • Normalizes multiline query strings and converts parameter values for CharSequence, collections, and arrays.
    • Provides expand(...) returning Expanded(query, parameters).
  2. QuerySettings:

    • Encapsulates query execution settings (such as max, offset, timeout, flushMode) with defensive copying.
    • Filters JPA hints against AvailableHints.getDefinedHints().
    • Provides lookup accessors by String and HibernateQueryArgument enum constants.
  3. HqlQueryContext:

    • Refactored into a thin record composing the resolved HQL, targetClass, QueryParameters, QuerySettings, and update/native flags.
    • Preserves binary and source compatibility: deprecates the 8-parameter constructor, shims (namedParams(), positionalParams(), querySettings(), hints()), and static resolution methods with @Deprecated(since = "8.0.1", forRemoval = true).
  4. Internal Callers:

    • Updated SelectHqlQuery, MutationHqlQuery, and HqlQueryMethods to consume QueryParameters and QuerySettings directly.
    • Added HqlQueryMethods.populateParameters(HqlQueryDelegate, QueryParameters) and deprecated the context-based overload.
  5. Tests:

    • Added unit specifications QueryParametersSpec and QuerySettingsSpec.

…QuerySettings

Extract QueryParameters to encapsulate named and positional parameters, GString
query expansion, and parameter value conversion. Extract QuerySettings to manage
query arguments and filter JPA hints against AvailableHints.

Refactor HqlQueryContext into an immutable record composing the resolved HQL,
target class, QueryParameters, QuerySettings, and update/native flags, while
preserving compatibility accessors and constructors.
Copilot AI balanced review requested due to automatic review settings October 30, 2026 11:55

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.

… and deprecate shims

Update SelectHqlQuery, MutationHqlQuery, and HqlQueryMethods to consume
QueryParameters and QuerySettings directly. Deprecate legacy compatibility
accessors and constructors on HqlQueryContext and HqlQueryMethods.
@testlens-app

testlens-app Bot commented Oct 30, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 0b4764a
▶️ Tests: 95523 executed
⚪️ Checks: 96/96 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.

Query preparation, GString expansion, parameter conversion, and hint filtering stay on the same path after the settings move. SELECT and mutation settings stay separate.

@borinquenkid
borinquenkid merged commit 8803d54 into 8.0.x Oct 30, 2026
97 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.

Hibernate 7: split HqlQueryContext into HqlText, QueryParameters and QuerySettings

3 participants