Skip to content

fix: align H7 HibernateGormStaticApi internal SQL method names with H5#15768

Open
borinquenkid wants to merge 5 commits into
8.0.xfrom
fix/h7-hide-native-sql-method-names
Open

fix: align H7 HibernateGormStaticApi internal SQL method names with H5#15768
borinquenkid wants to merge 5 commits into
8.0.xfrom
fix/h7-hide-native-sql-method-names

Conversation

@borinquenkid

Copy link
Copy Markdown
Member

Rename findWithNativeSql/findAllWithNativeSql to findWithSql/findAllWithSql in HibernateGormStaticApi so the Native suffix is not visible outside the implementation. HibernateEntity already exposes the correct public names; only the internal delegation calls are updated.

Description

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

  • This PR is linked to an existing issue that has been acknowledged or approved by the project team. If no approved issue exists, please give background on why this change is necessary. Tickets are preferred for release change log history.
  • This PR addresses the complete scope of the linked issue. Partial implementations or unfinished work should not be submitted for review.
  • [X ] This PR contains a single, focused change. Unrelated changes should be submitted as separate pull requests.
  • This PR targets the correct branch for the type of change:
    • Patch release branches (e.g., 7.0.x): Bug fixes only. No new features or API changes.
    • Minor release branches (e.g., 7.1.x): New features are welcome, but breaking existing APIs must be avoided.
    • Major release branches (e.g., 8.0.x): Reserved for major changes. Breaking API changes are permitted.

Code Quality

  • [ X] I have added or updated tests that cover the changes introduced in this PR. All code contributions are expected to include appropriate test coverage.
  • [X ] I have verified that all existing tests pass by running ./gradlew build --rerun-tasks.
  • [ X] My code follows the project's code style guidelines. I have run ./gradlew codeStyle and resolved any violations. See Code Style for details.
  • [X ] This PR does not include mass reformatting, style-only changes, or large-scale refactoring unless it was explicitly approved in the linked issue. Unsolicited reformatting will not be accepted.
  • [ X] If generative AI tooling was used in preparing this contribution, a quality model was used to ensure contributions are consistent with the project's quality standards.

Licensing and Attribution

  • [X ] All contributed code is provided under the Apache License 2.0, and new source files include the appropriate Apache license header.
  • [X ] I have the necessary rights to submit this contribution and confirm it is my own original work (see Legal Notice).
  • [ X] If generative AI tooling was used in preparing this contribution, I have followed the Apache Software Foundation's policy on generative tooling and have properly attributed its use.

Documentation

  • If this PR introduces user-facing changes, I have included or updated the relevant documentation.
  • If this PR adds a new feature, I have updated the What's New section of the Grails Guide.
  • If this PR introduces breaking changes or changes that require user action during an upgrade, I have updated the Upgrade Notes for the corresponding version in the Grails Guide.
  • [ X] The PR description clearly explains what was changed and why.

First-time contributors: Please read our Contributing Guide before submitting.
Pull requests that appear to be auto-generated, incomplete, or unrelated to an approved issue may be
closed to help maintainers focus on reviewed and planned work. We appreciate your understanding.

Rename findWithNativeSql/findAllWithNativeSql to findWithSql/findAllWithSql
in HibernateGormStaticApi so the Native suffix is not visible outside the
implementation. HibernateEntity already exposes the correct public names;
only the internal delegation calls are updated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 25, 2026 18:07
@borinquenkid borinquenkid requested a review from matrei June 25, 2026 18:07

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.

Pull request overview

This PR updates the Hibernate 7 GORM static API to use findWithSql / findAllWithSql method names (matching the Hibernate 5 naming) and adjusts HibernateEntity to delegate to those updated method names.

Changes:

  • Renamed HibernateGormStaticApi internal native-SQL methods from findWithNativeSql / findAllWithNativeSql to findWithSql / findAllWithSql.
  • Updated HibernateEntity trait delegation calls to match the renamed static API methods.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy Renames the static API native SQL method names to *WithSql.
grails-data-hibernate7/core/src/main/groovy/grails/gorm/hibernate/HibernateEntity.groovy Updates trait delegation to call the renamed HibernateGormStaticApi methods.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@matrei matrei 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.

The documentation also needs updating.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.2540%. Comparing base (0a334c8) to head (5b6d775).

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                8.0.x     #15768        +/-   ##
==================================================
- Coverage     49.2583%   49.2540%   -0.0043%     
+ Complexity      16506      16502         -4     
==================================================
  Files            1941       1941                
  Lines           92023      92023                
  Branches        16062      16062                
==================================================
- Hits            45329      45325         -4     
- Misses          39649      39655         +6     
+ Partials         7045       7043         -2     

see 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@borinquenkid

Copy link
Copy Markdown
Member Author

The documentation also needs updating.

We never exposed this to the public we have not release a milestone. I am very confused.

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Keep Hibernate 7 SQL helper documentation aligned with the historical Hibernate 5 GORM API names findWithSql and findAllWithSql. Remove the unreleased NativeSql method names from the H7 guide and keep the static API signature wording consistent.

Assisted-by: opencode:openai/gpt-5.5
@jamesfredley

Copy link
Copy Markdown
Contributor

Pushed follow-up commit 92b2c98.

This keeps the H7 SQL helper API aligned with the historical Hibernate 5/GORM names: findWithSql and findAllWithSql. The H7 docs now describe those names directly and no longer advertise the unreleased findWithNativeSql / findAllWithNativeSql names or mark the historical names as deprecated.

Verified with JDK 21:

  • ./gradlew :grails-data-hibernate7-core:test --tests grails.gorm.tests.SqlQuerySpec --tests org.grails.orm.hibernate.HibernateGormStaticApiSpec -x :grails-test-report:markdownAggregateTestReport
  • ./gradlew :grails-data-hibernate7-docs:docs
  • rendered H7 manual page shows SQL Queries with findWithSql / findAllWithSql only.

@jamesfredley jamesfredley requested a review from matrei June 26, 2026 16:31
@jamesfredley

Copy link
Copy Markdown
Contributor

@borinquenkid @matrei I believe this is all polished up.

GORM provides `findWithSql` and `findAllWithSql` for executing raw SQL when HQL or the Criteria API cannot express the query you need (e.g. database-specific functions, complex joins, or legacy SQL).

WARNING: Native SQL bypasses Hibernate's type system and object mapping. Prefer HQL, the Criteria API, or dynamic finders wherever possible. Use native SQL only when there is no higher-level alternative.
WARNING: Raw SQL bypasses Hibernate's type system and object mapping. Prefer HQL, the Criteria API, or dynamic finders wherever possible. Use SQL only when there is no higher-level alternative.

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.

Shouldn't this say DetachedCriteria?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we dont use JPA Criteria , we use GORM DetachedCriteria

===== SQL query helpers

`findWithSql` and `findAllWithSql` are deprecated. Use `findWithNativeSql` and `findAllWithNativeSql` instead. The old names remain as delegating aliases for backwards compatibility.
Hibernate 7 keeps the Hibernate 5 method names for raw SQL query helpers:

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.

Why do we need to mention this?

Removed mention of Hibernate 5 method names for raw SQL query helpers.
@testlens-app

testlens-app Bot commented Jun 26, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 1e57996
▶️ Tests: 19086 executed
⚪️ Checks: 44/44 completed


Learn more about TestLens at testlens.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants