You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ja...@apache.org on 2026/06/11 18:37:39 UTC
(grails-core) branch test/h7-functional-coverage created (now 2e0265328b)
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a change to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
at 2e0265328b Normalize H7 GORM bug report typography
This branch includes the following new commits:
new 8b7958a2e8 Merge remote-tracking branch 'origin/ci/hibernate-matrix-testing' into test/h7-functional-coverage
new 62e54ff22a Require Hibernate functional checks before publish
new 5aaa296b36 Align Hibernate 7 functional dependency routing
new 794ce6834a Match Hibernate 7 static finder parity
new 6d0aaa5241 Apply Hibernate 7 HQL query settings consistently
new b269c009b9 Restore migrated Hibernate 7 TCK spec wiring
new d4963e7d52 Fix Hibernate 7 has-many support import
new 49c80643ea Scan Hibernate 7 multitenancy support package
new 74bfe690ef Document Hibernate 7 HQL query settings
new fcf88e96b5 Document Hibernate 7 finder and getAll behavior
new da46aed134 Mark H7 GORM bug report historical
new 2e0265328b Normalize H7 GORM bug report typography
The 12 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(grails-core) 10/12: Document Hibernate 7 finder and getAll behavior
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit fcf88e96b5e7bd46d99f783837de3aaee727f091
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 14:17:11 2026 -0400
Document Hibernate 7 finder and getAll behavior
Assisted-by: Hephaestus:openai/gpt-5.5
---
.../docs/src/docs/asciidoc/quickStartGuide/basicCRUD.adoc | 7 +++++++
grails-doc/src/en/ref/Domain Classes/findAllWhere.adoc | 5 +++++
grails-doc/src/en/ref/Domain Classes/findWhere.adoc | 5 +++++
grails-doc/src/en/ref/Domain Classes/getAll.adoc | 2 ++
4 files changed, 19 insertions(+)
diff --git a/grails-data-hibernate7/docs/src/docs/asciidoc/quickStartGuide/basicCRUD.adoc b/grails-data-hibernate7/docs/src/docs/asciidoc/quickStartGuide/basicCRUD.adoc
index 1f78dce296..ca1b0e1d8e 100644
--- a/grails-data-hibernate7/docs/src/docs/asciidoc/quickStartGuide/basicCRUD.adoc
+++ b/grails-data-hibernate7/docs/src/docs/asciidoc/quickStartGuide/basicCRUD.adoc
@@ -46,6 +46,9 @@ def book = Book.get(999) // null
// Get multiple by IDs
def books = Book.getAll(1, 2, 3)
+// The returned list preserves the supplied id order
+def books = Book.getAll(3, 1, 2)
+
// Load a proxy (no immediate SELECT)
def book = Book.load(1)
@@ -59,6 +62,10 @@ def books = Book.list(max: 10, offset: 0, sort: 'title', order: 'asc')
def book = Book.findByTitle('Groovy in Action')
def books = Book.findAllByAuthor('Dierk König')
def count = Book.countByAuthor('Dierk König')
+
+// Property-map queries; null values match null properties
+def unreleased = Book.findWhere(releaseDate: null)
+def matching = Book.findAllWhere(author: 'Dierk König', releaseDate: null)
----
=== Update
diff --git a/grails-doc/src/en/ref/Domain Classes/findAllWhere.adoc b/grails-doc/src/en/ref/Domain Classes/findAllWhere.adoc
index 2ca643b29c..8ce1c9380f 100644
--- a/grails-doc/src/en/ref/Domain Classes/findAllWhere.adoc
+++ b/grails-doc/src/en/ref/Domain Classes/findAllWhere.adoc
@@ -60,6 +60,11 @@ def unreleasedBooks = Book.findAllWhere(releaseDate: null)
=== Description
+`findAllWhere` returns all matching instances. A `null` value in the argument map matches rows where that property is `null`.
+
+Only domain class property names may be used as keys in the argument map. Invalid property names are rejected instead of being interpolated into the generated query.
+
Parameters:
* `queryParams` - A Map of key/value pairs to be used in the query
+* `args` - Optional query arguments such as `max`, `offset`, `cache`, `readOnly`, `fetchSize`, `timeout`, `flushMode`, and `lock`
diff --git a/grails-doc/src/en/ref/Domain Classes/findWhere.adoc b/grails-doc/src/en/ref/Domain Classes/findWhere.adoc
index 591bd0ab91..5dce3895c1 100644
--- a/grails-doc/src/en/ref/Domain Classes/findWhere.adoc
+++ b/grails-doc/src/en/ref/Domain Classes/findWhere.adoc
@@ -62,6 +62,11 @@ boolean isReleased = Book.findWhere(author: "Stephen King",
=== Description
+`findWhere` returns the first matching instance, or `null` when no instance matches. A `null` value in the argument map matches rows where that property is `null`.
+
+Only domain class property names may be used as keys in the argument map. Invalid property names are rejected instead of being interpolated into the generated query.
+
Parameters:
* `queryParams` - A `Map` of key/value pairs to be used in the query
+* `args` - Optional query arguments such as `offset`, `cache`, `readOnly`, `fetchSize`, `timeout`, `flushMode`, and `lock`. `findWhere` always limits the query to one result.
diff --git a/grails-doc/src/en/ref/Domain Classes/getAll.adoc b/grails-doc/src/en/ref/Domain Classes/getAll.adoc
index bd8d3fc1e1..e9fb04f576 100644
--- a/grails-doc/src/en/ref/Domain Classes/getAll.adoc
+++ b/grails-doc/src/en/ref/Domain Classes/getAll.adoc
@@ -48,6 +48,8 @@ def bookList = Book.getAll()
=== Description
+The returned list preserves the order of the ids supplied by the caller. If an id is `null` or does not exist, the corresponding position in the returned list is `null`.
+
Parameters:
* `varargs`* - A variable argument list of ids
(grails-core) 08/12: Scan Hibernate 7 multitenancy support package
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 49c80643ea92167f92b46780e7241abe4c29e515
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 14:07:20 2026 -0400
Scan Hibernate 7 multitenancy support package
Assisted-by: Hephaestus:openai/gpt-5.5
---
.../multitenancy/MultiTenancyBidirectionalManyToManySpec.groovy | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/multitenancy/MultiTenancyBidirectionalManyToManySpec.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/multitenancy/MultiTenancyBidirectionalManyToManySpec.groovy
index 4b79f42e66..ea7c9759ca 100644
--- a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/multitenancy/MultiTenancyBidirectionalManyToManySpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/multitenancy/MultiTenancyBidirectionalManyToManySpec.groovy
@@ -20,6 +20,10 @@ package grails.gorm.tests.multitenancy
import grails.gorm.transactions.Rollback
+import grails.gorm.specs.multitenancy.Department
+import grails.gorm.specs.multitenancy.DepartmentService
+import grails.gorm.specs.multitenancy.User
+import grails.gorm.specs.multitenancy.UserService
import org.grails.datastore.mapping.core.DatastoreUtils
import org.grails.datastore.mapping.multitenancy.MultiTenancySettings
import org.grails.datastore.mapping.multitenancy.resolvers.SystemPropertyTenantResolver
@@ -57,7 +61,7 @@ class MultiTenancyBidirectionalManyToManySpec extends Specification {
void setup() {
System.setProperty(SystemPropertyTenantResolver.PROPERTY_NAME, "oci")
- datastore = new HibernateDatastore(DatastoreUtils.createPropertyResolver(config), getClass().getPackage())
+ datastore = new HibernateDatastore(DatastoreUtils.createPropertyResolver(config), Department.getPackage())
departmentService = datastore.getService(DepartmentService)
userService = datastore.getService(UserService)
}
@@ -86,4 +90,4 @@ class MultiTenancyBidirectionalManyToManySpec extends Specification {
department.users.size()
}
-}
\ No newline at end of file
+}
(grails-core) 05/12: Apply Hibernate 7 HQL query settings consistently
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 6d0aaa5241b3b771655324baf6f541031baff21e
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 13:59:13 2026 -0400
Apply Hibernate 7 HQL query settings consistently
Assisted-by: Hephaestus:openai/gpt-5.5
---
.../orm/hibernate/query/HqlQueryMethods.java | 37 +++++++++++++++++++---
.../grails/orm/hibernate/query/SelectHqlQuery.java | 4 +--
.../orm/hibernate/query/HqlQueryMethodsSpec.groovy | 33 ++++++++++++++++---
.../orm/hibernate/query/SelectHqlQuerySpec.groovy | 11 +++++++
4 files changed, 75 insertions(+), 10 deletions(-)
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryMethods.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryMethods.java
index 3f3559fad2..9d80213d41 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryMethods.java
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryMethods.java
@@ -25,6 +25,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import jakarta.persistence.LockModeType;
+
public interface HqlQueryMethods {
Set<String> INTERNAL_SETTINGS = Set.of(
@@ -34,7 +36,8 @@ public interface HqlQueryMethods {
HibernateQueryArgument.READ_ONLY.value(),
HibernateQueryArgument.FETCH_SIZE.value(),
HibernateQueryArgument.MAX.value(),
- HibernateQueryArgument.OFFSET.value()
+ HibernateQueryArgument.OFFSET.value(),
+ HibernateQueryArgument.LOCK.value()
);
default void populateQuerySettings(HqlQueryDelegate d, Map<String, Object> args) {
@@ -43,14 +46,40 @@ public interface HqlQueryMethods {
d.setQueryFlushMode(GrailsQueryFlushMode.mapToHibernateQueryFlushMode(args.get(HibernateQueryArgument.FLUSH_MODE.value())));
}
if (args.containsKey(HibernateQueryArgument.MAX.value())) {
- d.setMaxResults((Integer) args.get(HibernateQueryArgument.MAX.value()));
+ d.setMaxResults(toInteger(args.get(HibernateQueryArgument.MAX.value())));
}
if (args.containsKey(HibernateQueryArgument.OFFSET.value())) {
- d.setFirstResult((Integer) args.get(HibernateQueryArgument.OFFSET.value()));
+ d.setFirstResult(toInteger(args.get(HibernateQueryArgument.OFFSET.value())));
+ }
+ if (args.containsKey(HibernateQueryArgument.FETCH_SIZE.value())) {
+ d.setFetchSize(toInteger(args.get(HibernateQueryArgument.FETCH_SIZE.value())));
+ }
+ if (args.containsKey(HibernateQueryArgument.TIMEOUT.value())) {
+ d.setTimeout(toInteger(args.get(HibernateQueryArgument.TIMEOUT.value())));
}
if (args.containsKey(HibernateQueryArgument.READ_ONLY.value())) {
- d.setReadOnly((Boolean) args.get(HibernateQueryArgument.READ_ONLY.value()));
+ d.setReadOnly(toBoolean(args.get(HibernateQueryArgument.READ_ONLY.value())));
+ }
+ if (toBoolean(args.get(HibernateQueryArgument.LOCK.value()))) {
+ d.setLockMode(LockModeType.PESSIMISTIC_WRITE);
+ d.setCacheable(false);
+ } else if (args.containsKey(HibernateQueryArgument.CACHE.value())) {
+ d.setCacheable(toBoolean(args.get(HibernateQueryArgument.CACHE.value())));
+ }
+ }
+
+ static int toInteger(Object value) {
+ if (value instanceof Number number) {
+ return number.intValue();
+ }
+ return Integer.parseInt(value.toString());
+ }
+
+ static boolean toBoolean(Object value) {
+ if (value instanceof Boolean bool) {
+ return bool;
}
+ return value != null && Boolean.parseBoolean(value.toString());
}
default void populateHints(HqlQueryDelegate d, Map<String, Object> hints) {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SelectHqlQuery.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SelectHqlQuery.java
index eadc7c8071..76f27fcd65 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SelectHqlQuery.java
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SelectHqlQuery.java
@@ -96,7 +96,7 @@ public class SelectHqlQuery extends Query implements HqlQueryMethods, Serializab
return max;
}
Object m = queryContext.querySettings().get(HibernateQueryArgument.MAX.value());
- return m instanceof Number n ? n.intValue() : -1;
+ return m == null ? -1 : HqlQueryMethods.toInteger(m);
}
@Override
@@ -105,6 +105,6 @@ public class SelectHqlQuery extends Query implements HqlQueryMethods, Serializab
return offset;
}
Object o = queryContext.querySettings().get(HibernateQueryArgument.OFFSET.value());
- return o instanceof Number n ? n.intValue() : 0;
+ return o == null ? 0 : HqlQueryMethods.toInteger(o);
}
}
diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/HqlQueryMethodsSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/HqlQueryMethodsSpec.groovy
index a6ad612e1d..4dbd386ea0 100644
--- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/HqlQueryMethodsSpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/HqlQueryMethodsSpec.groovy
@@ -19,6 +19,7 @@
package org.grails.orm.hibernate.query
import org.grails.orm.hibernate.query.HibernateQueryArgument
+import jakarta.persistence.LockModeType
import spock.lang.Specification
import org.hibernate.query.QueryFlushMode
@@ -64,9 +65,12 @@ class HqlQueryMethodsSpec extends Specification {
def delegate = Mock(HqlQueryDelegate)
def settings = [
(HibernateQueryArgument.FLUSH_MODE.value()): "COMMIT",
- (HibernateQueryArgument.MAX.value()): 10,
- (HibernateQueryArgument.OFFSET.value()): 5,
- (HibernateQueryArgument.READ_ONLY.value()): true
+ (HibernateQueryArgument.MAX.value()): '10',
+ (HibernateQueryArgument.OFFSET.value()): '5',
+ (HibernateQueryArgument.FETCH_SIZE.value()): '50',
+ (HibernateQueryArgument.TIMEOUT.value()): '30',
+ (HibernateQueryArgument.READ_ONLY.value()): 'true',
+ (HibernateQueryArgument.CACHE.value()): 'true'
]
when:
@@ -76,7 +80,27 @@ class HqlQueryMethodsSpec extends Specification {
1 * delegate.setQueryFlushMode(QueryFlushMode.NO_FLUSH)
1 * delegate.setMaxResults(10)
1 * delegate.setFirstResult(5)
+ 1 * delegate.setFetchSize(50)
+ 1 * delegate.setTimeout(30)
1 * delegate.setReadOnly(true)
+ 1 * delegate.setCacheable(true)
+ }
+
+ void "test populateQuerySettings applies lock and disables cache"() {
+ given:
+ def delegate = Mock(HqlQueryDelegate)
+ def settings = [
+ (HibernateQueryArgument.LOCK.value()): 'true',
+ (HibernateQueryArgument.CACHE.value()): 'true'
+ ]
+
+ when:
+ queryMethods.populateQuerySettings(delegate, settings)
+
+ then:
+ 1 * delegate.setLockMode(LockModeType.PESSIMISTIC_WRITE)
+ 1 * delegate.setCacheable(false)
+ 0 * delegate.setCacheable(true)
}
void "test populateParameters with named parameters"() {
@@ -96,13 +120,14 @@ class HqlQueryMethodsSpec extends Specification {
void "test populateParameters filters internal settings"() {
given:
def delegate = Mock(HqlQueryDelegate)
- def ctx = new HqlQueryContext("hql", Object, [(HibernateQueryArgument.MAX.value()): 10, title: "GORM"], [], [:], [:], false, false)
+ def ctx = new HqlQueryContext("hql", Object, [(HibernateQueryArgument.MAX.value()): 10, (HibernateQueryArgument.LOCK.value()): true, title: "GORM"], [], [:], [:], false, false)
when:
HqlQueryMethods.populateParameters(delegate, ctx)
then:
0 * delegate.setParameter(HibernateQueryArgument.MAX.value(), _)
+ 0 * delegate.setParameter(HibernateQueryArgument.LOCK.value(), _)
1 * delegate.setParameter("title", "GORM")
}
diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/SelectHqlQuerySpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/SelectHqlQuerySpec.groovy
index 8c947936bf..3642ef198b 100644
--- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/SelectHqlQuerySpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/SelectHqlQuerySpec.groovy
@@ -141,6 +141,17 @@ class SelectHqlQuerySpec extends HibernateGormDatastoreSpec {
results.size() == 1
}
+ void "createHqlQuery exposes converted max and offset args"() {
+ when:
+ def query = buildHqlQuery("from SelectHqlQuerySpecBook order by title", [:], null, [max: '2', offset: '1'])
+ def results = query.list()
+
+ then:
+ query.max == 2
+ query.offset == 1
+ results.size() == 2
+ }
+
void "createHqlQuery with empty query string defaults to full entity query"() {
when:
def results = buildHqlQuery("").list()
(grails-core) 07/12: Fix Hibernate 7 has-many support import
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit d4963e7d52e8c5f74e6f2dc6ec5c9fe2734f43fb
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 14:05:23 2026 -0400
Fix Hibernate 7 has-many support import
Assisted-by: Hephaestus:openai/gpt-5.5
---
.../core/src/test/groovy/grails/gorm/tests/hasmany/Something.groovy | 2 ++
1 file changed, 2 insertions(+)
diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hasmany/Something.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hasmany/Something.groovy
index 3512510941..cc06d86bfc 100644
--- a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hasmany/Something.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hasmany/Something.groovy
@@ -19,6 +19,8 @@
package grails.gorm.specs.hasmany
+import grails.gorm.tests.hasmany.Book
+
class Something {
public static void main(String[] args) {
(grails-core) 12/12: Normalize H7 GORM bug report typography
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 2e0265328b3b44d6c6cb3d0c8d30864a130189fb
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 14:36:22 2026 -0400
Normalize H7 GORM bug report typography
Assisted-by: Hephaestus:openai/gpt-5.5
---
H7_GORM_BUG_REPORT.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/H7_GORM_BUG_REPORT.md b/H7_GORM_BUG_REPORT.md
index 5911069c7f..0434a88734 100644
--- a/H7_GORM_BUG_REPORT.md
+++ b/H7_GORM_BUG_REPORT.md
@@ -32,7 +32,7 @@ Before those fixes, running `grails-test-examples-gorm` with `-PhibernateVersion
**Description:** H7 intentionally rejects `executeQuery("from Book where inStock = true")` when no parameters are passed. The same tightening was already applied to `executeUpdate`. Callers must use `executeQuery('...', [:])` or a GString with interpolated params.
-> This is by design. The test bodies need to adopt the parameterized form — not a GORM bug.
+> This is by design. The test bodies need to adopt the parameterized form - not a GORM bug.
---
@@ -72,7 +72,7 @@ Before those fixes, running `grails-test-examples-gorm` with `-PhibernateVersion
| **Spec** | `GormDataServicesSpec` |
| **Errors** | `Incorrect query result type: query produces 'java.lang.Double' but type 'java.lang.Long' was given` / `query produces 'java.lang.Integer' but type 'java.lang.Long' was given` |
-**Description:** `HibernateHqlQuery.buildQuery()` always calls `session.createQuery(hql, ctx.targetClass())`. For aggregate HQL (`select avg(b.price) ...`, `select max(b.pageCount) ...`), the query does not return an entity, but `ctx.targetClass()` returns the entity class (e.g., `Book`). H7's `SqmQueryImpl` enforces strict result-type alignment — `avg()` produces `Double`, `max(pageCount)` produces `Integer`, neither is coercible to the bound entity type.
+**Description:** `HibernateHqlQuery.buildQuery()` always calls `session.createQuery(hql, ctx.targetClass())`. For aggregate HQL (`select avg(b.price) ...`, `select max(b.pageCount) ...`), the query does not return an entity, but `ctx.targetClass()` returns the entity class (e.g., `Book`). H7's `SqmQueryImpl` enforces strict result-type alignment: `avg()` produces `Double`, `max(pageCount)` produces `Integer`, neither is coercible to the bound entity type.
**Expected fix:** `HibernateHqlQuery.buildQuery()` must detect non-entity HQL (aggregates / projections) and call the untyped `session.createQuery(hql)` in those cases, letting GORM handle result casting downstream.
(grails-core) 01/12: Merge remote-tracking branch 'origin/ci/hibernate-matrix-testing' into test/h7-functional-coverage
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 8b7958a2e847b41f19793925044d9d7b4e3445fb
Merge: 95e7400568 634c9e8e5e
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 09:57:14 2026 -0400
Merge remote-tracking branch 'origin/ci/hibernate-matrix-testing' into test/h7-functional-coverage
.github/workflows/gradle.yml | 11 +++-
H7_GORM_BUG_REPORT.md | 74 ++++++++++++++++++++++
dependencies.gradle | 5 +-
gradle/functional-test-config.gradle | 70 +++++++++++++++++++-
grails-forge/gradle.properties | 1 +
.../grails-forge-analytics-postgres/build.gradle | 2 +
.../gorm/grails-app/conf/application.yml | 6 +-
.../hyphenated/grails-app/conf/application.yml | 7 +-
8 files changed, 166 insertions(+), 10 deletions(-)
diff --cc .github/workflows/gradle.yml
index b13790bf31,e5e236b1ab..0838387d1d
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@@ -259,11 -256,12 +261,13 @@@ jobs
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
with:
+ cache-provider: basic # 'basic' uses the MIT-licensed, open-source cache provider; the default 'enhanced' provider (v6+) is proprietary (Gradle commercial Terms of Use)
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Setup TestLens"
- uses: testlens-app/setup-testlens@v1
+ uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2
- name: "🏃 Run Functional Tests"
+ env:
+ GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew bootJar check
--continue
(grails-core) 11/12: Mark H7 GORM bug report historical
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit da46aed134cdd3269dbe81b7761b509820a80a37
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 14:33:40 2026 -0400
Mark H7 GORM bug report historical
Assisted-by: Hephaestus:openai/gpt-5.5
---
H7_GORM_BUG_REPORT.md | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/H7_GORM_BUG_REPORT.md b/H7_GORM_BUG_REPORT.md
index 1ce4fc4bb5..5911069c7f 100644
--- a/H7_GORM_BUG_REPORT.md
+++ b/H7_GORM_BUG_REPORT.md
@@ -1,11 +1,28 @@
-## H7 `gorm` Functional Test Failures — Bug Report
+<!--
+SPDX-License-Identifier: Apache-2.0
-Running `grails-test-examples-gorm` with `-PhibernateVersion=7` produces 13 failures across 4 specs.
-Below are the 5 distinct root causes.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+## Historical H7 `gorm` Functional Test Failures - Bug Report
+
+This historical report captured the `grails-test-examples-gorm` failures that drove the Hibernate 7 fixes in this branch. Some entries below have since been fixed by this branch, so treat this file as triage rationale rather than current expected test status.
+
+Before those fixes, running `grails-test-examples-gorm` with `-PhibernateVersion=7` produced 13 failures across 4 specs. Below are the 5 distinct root causes.
---
-### Bug 1 (Intentional) — `executeQuery` / `executeUpdate` plain String blocked
+### Bug 1 (Intentional) - `executeQuery` / `executeUpdate` plain String blocked
| | |
|---|---|
@@ -19,7 +36,7 @@ Below are the 5 distinct root causes.
---
-### Bug 2 — `DetachedCriteria.get()` throws `NonUniqueResultException` instead of returning first result
+### Bug 2 - `DetachedCriteria.get()` throws `NonUniqueResultException` instead of returning first result
| | |
|---|---|
@@ -33,7 +50,7 @@ Below are the 5 distinct root causes.
---
-### Bug 3 — `Found two representations of same collection: gorm.Author.books`
+### Bug 3 - `Found two representations of same collection: gorm.Author.books`
| | |
|---|---|
@@ -47,7 +64,7 @@ Below are the 5 distinct root causes.
---
-### Bug 4 — `@Query` aggregate functions fail with type mismatch
+### Bug 4 - `@Query` aggregate functions fail with type mismatch
| | |
|---|---|
@@ -61,7 +78,7 @@ Below are the 5 distinct root causes.
---
-### Bug 5 — `where { pageCount > price * 10 }` fails with `CoercionException`
+### Bug 5 - `where { pageCount > price * 10 }` fails with `CoercionException`
| | |
|---|---|
(grails-core) 04/12: Match Hibernate 7 static finder parity
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 794ce6834abeffce927d42e0c32c6ebb3b6b544c
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 13:53:21 2026 -0400
Match Hibernate 7 static finder parity
Assisted-by: Hephaestus:openai/gpt-5.5
---
.../orm/hibernate/HibernateGormStaticApi.groovy | 29 ++++++--
.../HibernateGormStaticApiFindWhereSpec.groovy | 82 ++++++++++++++++++++++
.../hibernate/HibernateGormStaticApiSpec.groovy | 68 +++++++++++++++++-
3 files changed, 173 insertions(+), 6 deletions(-)
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy
index 4a47afc391..036e0ffeaf 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy
@@ -60,6 +60,7 @@ import org.grails.orm.hibernate.query.HibernateHqlQueryCreator
import org.grails.orm.hibernate.query.HibernatePagedResultList
import org.grails.orm.hibernate.query.MutationHqlQuery
import org.grails.orm.hibernate.query.HibernateQuery
+import org.grails.orm.hibernate.query.HibernateQueryArgument
import org.grails.orm.hibernate.query.HqlListQueryBuilder
import org.grails.orm.hibernate.query.HqlQueryContext
import org.grails.orm.hibernate.support.HibernateRuntimeUtils
@@ -353,7 +354,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
if (!queryMap) return null
Map coercedMap = queryMap.collectEntries { k, v -> [k.toString(), v] }
String hql = buildWhereHql(coercedMap)
- doSingleInternal(hql, coercedMap, [], args, false)
+ doSingleInternal(hql, buildWhereParams(coercedMap), [], buildFindWhereArgs(args), false)
}
@Override
@@ -361,14 +362,34 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
if (!queryMap) return null
Map coercedMap = queryMap.collectEntries { k, v -> [k.toString(), v] }
String hql = buildWhereHql(coercedMap)
- doListInternal(hql, coercedMap, [], args, false)
+ doListInternal(hql, buildWhereParams(coercedMap), [], args, false)
}
private String buildWhereHql(Map queryMap) {
- String whereClause = queryMap.keySet().collect { Object key -> "$key = :$key" }.join(' and ')
+ String whereClause = queryMap.collect { Object key, Object value ->
+ String propertyName = validateWherePropertyName(key.toString())
+ value == null ? "$propertyName is null" : "$propertyName = :$propertyName"
+ }.join(' and ')
return "from ${persistentEntity.name} where $whereClause"
}
+ private String validateWherePropertyName(String propertyName) {
+ if (persistentEntity.getPropertyByName(propertyName) == null) {
+ throw new IllegalArgumentException("Property [$propertyName] is not a valid property of ${persistentEntity.name}")
+ }
+ return propertyName
+ }
+
+ private static Map buildWhereParams(Map queryMap) {
+ queryMap.findAll { Object key, Object value -> value != null }
+ }
+
+ private static Map buildFindWhereArgs(Map args) {
+ Map queryArgs = args ? new LinkedHashMap(args) : [:]
+ queryArgs[HibernateQueryArgument.MAX.value()] = 1
+ return queryArgs
+ }
+
@Override
List executeQuery(CharSequence query, Map namedParams, Map args) {
doListInternal(query, namedParams, [], args, false)
@@ -392,7 +413,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
List convertedIds = ids.collect { HibernateRuntimeUtils.convertValueToType(it, idType, conversionService) }
List<D> results = doListInternal("from $entity where $idName in (:ids)" as String, [ids: convertedIds], [], [:], false)
Map<Object, D> byId = results.collectEntries { [(it[idName]): it] }
- ids.collect { byId[it] }
+ convertedIds.collect { byId[it] }
}
@Override
diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiFindWhereSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiFindWhereSpec.groovy
new file mode 100644
index 0000000000..228d0dde64
--- /dev/null
+++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiFindWhereSpec.groovy
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.grails.orm.hibernate
+
+import java.util.Locale
+
+import grails.gorm.annotation.Entity
+import grails.gorm.transactions.Rollback
+import org.grails.datastore.mapping.core.DatastoreUtils
+import org.grails.orm.hibernate.cfg.Settings
+import org.hibernate.resource.jdbc.spi.StatementInspector
+import org.springframework.transaction.PlatformTransactionManager
+import spock.lang.AutoCleanup
+import spock.lang.Shared
+import spock.lang.Specification
+
+class HibernateGormStaticApiFindWhereSpec extends Specification {
+
+ @Shared SqlCapture sqlCapture = new SqlCapture()
+
+ @Shared @AutoCleanup HibernateDatastore hibernateDatastore = new HibernateDatastore(
+ DatastoreUtils.createPropertyResolver(
+ (Settings.SETTING_DB_CREATE): 'create-drop',
+ 'hibernate.session_factory.statement_inspector': sqlCapture
+ ),
+ FindWhereLimitEntity
+ )
+ @Shared PlatformTransactionManager transactionManager = hibernateDatastore.getTransactionManager()
+
+ @Rollback
+ void 'findWhere limits duplicate matches to one row'() {
+ given:
+ new FindWhereLimitEntity(name: 'duplicate').save(flush: true, failOnError: true)
+ new FindWhereLimitEntity(name: 'duplicate').save(flush: true, failOnError: true)
+ sqlCapture.clear()
+
+ when:
+ FindWhereLimitEntity result = FindWhereLimitEntity.findWhere(name: 'duplicate')
+
+ then:
+ result.name == 'duplicate'
+ sqlCapture.statements.any { String sql ->
+ String normalized = sql.toLowerCase(Locale.ENGLISH)
+ normalized.contains('where') && normalized.contains('fetch first') && normalized.contains('rows only')
+ }
+ }
+
+ static class SqlCapture implements StatementInspector {
+ final List<String> statements = Collections.synchronizedList(new ArrayList<String>())
+
+ @Override
+ String inspect(String sql) {
+ statements.add(sql)
+ return sql
+ }
+
+ void clear() {
+ statements.clear()
+ }
+ }
+}
+
+@Entity
+class FindWhereLimitEntity {
+ String name
+}
diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy
index 3c3dc32db9..4074709e88 100644
--- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy
@@ -22,7 +22,7 @@ package org.grails.orm.hibernate
import grails.gorm.specs.HibernateGormDatastoreSpec
import grails.gorm.annotation.Entity
-import grails.gorm.specs.entities.Club
+import grails.gorm.tests.entities.Club
class HibernateGormStaticApiSpec extends HibernateGormDatastoreSpec {
@@ -185,6 +185,50 @@ class HibernateGormStaticApiSpec extends HibernateGormDatastoreSpec {
instances.size() == 2
}
+ void "Test findWhere matches null values"() {
+ given:
+ new HibernateGormStaticApiEntity(name: "null-test", nullableName: null).save(failOnError: true)
+ new HibernateGormStaticApiEntity(name: "other", nullableName: "present").save(flush: true, failOnError: true)
+
+ when:
+ def instance = HibernateGormStaticApiEntity.findWhere(nullableName: null)
+
+ then:
+ instance.name == 'null-test'
+ }
+
+ void "Test findAllWhere matches null values"() {
+ given:
+ new HibernateGormStaticApiEntity(name: "null-test-1", nullableName: null).save(failOnError: true)
+ new HibernateGormStaticApiEntity(name: "null-test-2", nullableName: null).save(failOnError: true)
+ new HibernateGormStaticApiEntity(name: "other", nullableName: "present").save(flush: true, failOnError: true)
+
+ when:
+ def instances = HibernateGormStaticApiEntity.findAllWhere(nullableName: null)
+
+ then:
+ instances.size() == 2
+ instances*.name.containsAll(['null-test-1', 'null-test-2'])
+ }
+
+ void "Test findWhere rejects unsafe property names"() {
+ when:
+ HibernateGormStaticApiEntity.findWhere(['name) or 1=1 or (name': 'test'])
+
+ then:
+ def e = thrown(IllegalArgumentException)
+ e.message.contains('not a valid property')
+ }
+
+ void "Test findAllWhere rejects unsafe null-valued property names"() {
+ when:
+ HibernateGormStaticApiEntity.findAllWhere(['nullableName) is null or 1=1 or (nullableName': null])
+
+ then:
+ def e = thrown(IllegalArgumentException)
+ e.message.contains('not a valid property')
+ }
+
void "Test findAll with HQL using named params"() {
given:
new HibernateGormStaticApiEntity(name: "test1").save(failOnError: true)
@@ -519,6 +563,22 @@ class HibernateGormStaticApiSpec extends HibernateGormDatastoreSpec {
instances[2].id == e2.id
}
+ void "Test getAll preserves input order for convertible ids"() {
+ given:
+ def e1 = new HibernateGormStaticApiEntity(name: "first").save(failOnError: true)
+ def e2 = new HibernateGormStaticApiEntity(name: "second").save(failOnError: true)
+ def e3 = new HibernateGormStaticApiEntity(name: "third").save(flush: true, failOnError: true)
+
+ when: "ids are supplied as strings in reverse order"
+ def instances = HibernateGormStaticApiEntity.getAll([e3.id.toString(), e1.id.toString(), e2.id.toString()])
+
+ then: "results are ordered by the converted requested ids"
+ instances.size() == 3
+ instances[0].id == e3.id
+ instances[1].id == e1.id
+ instances[2].id == e2.id
+ }
+
void "Test getAll returns null in position for non-existent ids"() {
given:
def e1 = new HibernateGormStaticApiEntity(name: "exists").save(flush: true, failOnError: true)
@@ -877,10 +937,14 @@ class HibernateGormStaticApiSpec extends HibernateGormDatastoreSpec {
@Entity
class HibernateGormStaticApiEntity {
String name
+ String nullableName
+
+ static constraints = {
+ nullableName nullable: true
+ }
}
@Entity
class HibernateGormStaticApiMultiTenantEntity implements grails.gorm.MultiTenant<HibernateGormStaticApiMultiTenantEntity> {
String name
}
-
(grails-core) 03/12: Align Hibernate 7 functional dependency routing
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 5aaa296b36e96edbe128813e72abb1ada264b129
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 13:45:50 2026 -0400
Align Hibernate 7 functional dependency routing
Assisted-by: Hephaestus:openai/gpt-5.5
---
dependencies.gradle | 2 +-
gradle/functional-test-config.gradle | 13 ++++++++-----
grails-forge/grails-forge-analytics-postgres/build.gradle | 4 ++--
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/dependencies.gradle b/dependencies.gradle
index 0fe5a2080d..f89bebf2e8 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -317,7 +317,7 @@ ext {
'cache-ri-impl.version' : '1.1.1',
'groovy.version' : '5.0.5',
'hibernate-models.version' : '1.0.1',
- 'hibernate.version' : '7.2.5.Final',
+ 'hibernate.version' : '7.2.7.Final',
'jandex.version' : '3.2.3',
'liquibase-hibernate.version' : '4.27.0',
'liquibase-test-harness.version': '1.0.11',
diff --git a/gradle/functional-test-config.gradle b/gradle/functional-test-config.gradle
index d3bf5ccda2..a7e1a22998 100644
--- a/gradle/functional-test-config.gradle
+++ b/gradle/functional-test-config.gradle
@@ -35,9 +35,12 @@ boolean isHibernateSpecificProject = isHibernate5LabeledProject || isHibernate7L
boolean isMongoProject = project.name.startsWith('grails-test-examples-mongodb')
boolean isGeneralFunctionalTest = !isHibernateSpecificProject && !isMongoProject
-// General functional test projects that use Hibernate 5-specific GORM APIs and cannot run
-// under Hibernate 7 via dependency substitution.
-// Their H7-compatible equivalents live in grails-test-examples/hibernate7/.
+// General functional test projects that cannot run under Hibernate 7 via dependency substitution.
+// The datasources project has partial H7-compatible coverage in
+// grails-test-examples/hibernate7/grails-multiple-datasources, but still includes H5-only
+// coverage that needs explicit H7 duplicates before the general project can be enabled.
+// The views and scaffolding projects boot with H7 substitution, but their functional specs
+// currently fail on association rendering and unique-constraint behavior under Hibernate 7.
List<String> h7IncompatibleProjects = [
'grails-test-examples-datasources',
'grails-test-examples-views-functional-tests',
@@ -46,7 +49,7 @@ List<String> h7IncompatibleProjects = [
// Redirect the default grails-bom to grails-hibernate7-bom for general functional tests when
// running with -PhibernateVersion=7, so consumers get the Hibernate 7 version constraints
-// (hibernate.version=7.2.5.Final and related). The default grails-bom and grails-hibernate5-bom
+// (hibernate.version=7.2.7.Final and related). The default grails-bom and grails-hibernate5-bom
// ship the Hibernate 5 constraints.
def redirectBomToH7 = isGeneralFunctionalTest && targetHibernateVersion == '7' && !(project.name in h7IncompatibleProjects)
@@ -215,4 +218,4 @@ tasks.withType(Test).configureEach { Test task ->
tasks.named('groovydoc').configure {
// We don't need to generate docs for test projects
enabled = false
-}
\ No newline at end of file
+}
diff --git a/grails-forge/grails-forge-analytics-postgres/build.gradle b/grails-forge/grails-forge-analytics-postgres/build.gradle
index 09e016c9f8..04fe266cf8 100644
--- a/grails-forge/grails-forge-analytics-postgres/build.gradle
+++ b/grails-forge/grails-forge-analytics-postgres/build.gradle
@@ -28,11 +28,11 @@ group = 'org.apache.grails.forge'
dependencies {
- annotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
+ annotationProcessor platform("io.micronaut.platform:micronaut-platform:$micronautVersion")
annotationProcessor 'io.micronaut:micronaut-graal'
annotationProcessor 'io.micronaut.data:micronaut-data-processor'
- implementation platform("io.micronaut:micronaut-bom:$micronautVersion")
+ implementation platform("io.micronaut.platform:micronaut-platform:$micronautVersion")
implementation project(':grails-forge-core')
implementation "com.google.cloud.sql:postgres-socket-factory:$postgresSocketFactoryVersion"
implementation 'io.micronaut.data:micronaut-data-jdbc'
(grails-core) 02/12: Require Hibernate functional checks before publish
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 62e54ff22a483f5d0ebcada30dcdb61ee6fb9f35
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 13:41:33 2026 -0400
Require Hibernate functional checks before publish
Assisted-by: Hephaestus:openai/gpt-5.5
---
.github/workflows/gradle.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 0838387d1d..4f01b4da71 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -442,7 +442,7 @@ jobs:
name: grails-gradle-artifacts.txt
path: grails-gradle/build/grails-gradle-artifacts.txt
publish:
- needs: [ publishGradle, build, functional, mongodbFunctional ]
+ needs: [ publishGradle, build, functional, hibernate5Functional, hibernate7Functional, mongodbFunctional ]
if: >-
${{ always() &&
github.repository_owner == 'apache' &&
@@ -450,6 +450,8 @@ jobs:
needs.publishGradle.result == 'success' &&
(needs.build.result == 'success' || needs.build.result == 'skipped') &&
(needs.functional.result == 'success' || needs.functional.result == 'skipped') &&
+ (needs.hibernate5Functional.result == 'success' || needs.hibernate5Functional.result == 'skipped') &&
+ (needs.hibernate7Functional.result == 'success' || needs.hibernate7Functional.result == 'skipped') &&
(needs.mongodbFunctional.result == 'success' || needs.mongodbFunctional.result == 'skipped')
}}
runs-on: ubuntu-24.04
(grails-core) 06/12: Restore migrated Hibernate 7 TCK spec wiring
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit b269c009b97a2a6a89c9e6c82c77b01468ecdfb9
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 14:03:20 2026 -0400
Restore migrated Hibernate 7 TCK spec wiring
Assisted-by: Hephaestus:openai/gpt-5.5
---
.../groovy/grails/gorm/tests/Hibernate7OptimisticLockingSpec.groovy | 5 +----
.../groovy/grails/gorm/tests/TablePerSubClassAndEmbeddedSpec.groovy | 4 +++-
.../grails/gorm/tests/UniqueWithMultipleDataSourcesSpec.groovy | 4 ++--
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/Hibernate7OptimisticLockingSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/Hibernate7OptimisticLockingSpec.groovy
index 88d1e22bdb..c07e077b94 100644
--- a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/Hibernate7OptimisticLockingSpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/Hibernate7OptimisticLockingSpec.groovy
@@ -18,6 +18,7 @@
*/
package grails.gorm.tests
+import grails.gorm.specs.HibernateGormDatastoreSpec
import org.apache.grails.data.testing.tck.domains.OptLockNotVersioned
import org.apache.grails.data.testing.tck.domains.OptLockVersioned
import org.springframework.dao.OptimisticLockingFailureException
@@ -27,10 +28,6 @@ import org.springframework.dao.OptimisticLockingFailureException
*/
class Hibernate7OptimisticLockingSpec extends HibernateGormDatastoreSpec {
- def setupSpec() {
- manager.addAllDomainClasses([OptLockVersioned, OptLockNotVersioned])
- }
-
void "Test versioning"() {
given:
def o = new OptLockVersioned(name: 'locked')
diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/TablePerSubClassAndEmbeddedSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/TablePerSubClassAndEmbeddedSpec.groovy
index 18df300490..ec5d052b95 100644
--- a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/TablePerSubClassAndEmbeddedSpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/TablePerSubClassAndEmbeddedSpec.groovy
@@ -18,12 +18,14 @@
*/
package grails.gorm.tests
+import groovy.lang.GroovyClassLoader
+
import grails.gorm.DetachedCriteria
import grails.gorm.annotation.Entity
+import grails.gorm.specs.HibernateGormDatastoreSpec
import grails.gorm.transactions.Rollback
import org.grails.datastore.gorm.query.criteria.DetachedAssociationCriteria
import org.grails.datastore.gorm.query.transform.ApplyDetachedCriteriaTransform
-import spock.lang.Ignore
/**
* Created by graemerocher on 04/11/16.
diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/UniqueWithMultipleDataSourcesSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/UniqueWithMultipleDataSourcesSpec.groovy
index 46d1c65398..5dfdf7589d 100644
--- a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/UniqueWithMultipleDataSourcesSpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/UniqueWithMultipleDataSourcesSpec.groovy
@@ -19,11 +19,11 @@
package grails.gorm.tests
import grails.gorm.annotation.Entity
+import grails.gorm.specs.HibernateGormDatastoreSpec
import grails.gorm.transactions.Rollback
-import org.grails.datastore.mapping.core.Session
import org.grails.datastore.mapping.core.connections.ConnectionSource
import org.hibernate.dialect.H2Dialect
-import spock.lang.*
+import spock.lang.Issue
/**
* Created by graemerocher on 17/02/2017.
(grails-core) 09/12: Document Hibernate 7 HQL query settings
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch test/h7-functional-coverage
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 74bfe690efd9211d15452ed20494dbb62eec3e7e
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Jun 11 14:09:44 2026 -0400
Document Hibernate 7 HQL query settings
Assisted-by: Hephaestus:openai/gpt-5.5
---
.../docs/src/docs/asciidoc/querying/hql.adoc | 11 +++++++++--
grails-doc/src/en/ref/Domain Classes/executeQuery.adoc | 12 ++++++++++--
grails-doc/src/en/ref/Domain Classes/find.adoc | 2 +-
grails-doc/src/en/ref/Domain Classes/findAll.adoc | 3 ++-
4 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/grails-data-hibernate7/docs/src/docs/asciidoc/querying/hql.adoc b/grails-data-hibernate7/docs/src/docs/asciidoc/querying/hql.adoc
index 5d6a9c09c1..10678b813c 100644
--- a/grails-data-hibernate7/docs/src/docs/asciidoc/querying/hql.adoc
+++ b/grails-data-hibernate7/docs/src/docs/asciidoc/querying/hql.adoc
@@ -85,9 +85,9 @@ List results = Book.executeQuery(
['%Groovy%', 'Tech'])
----
-=== Pagination and Sorting
+=== Query Settings
-All `findAll` and `executeQuery` overloads accept a settings map as the last argument:
+`find`, `findAll`, and `executeQuery` overloads accept a settings map as the last argument. Use it for pagination and Hibernate query settings such as `cache`, `readOnly`, `fetchSize`, `timeout`, `flushMode`, and `lock`:
[source,groovy]
----
@@ -99,8 +99,15 @@ List results = Book.executeQuery(
"from Book b where b.genre = :genre",
[genre: 'Tech'],
[max: 5, offset: 0, cache: true])
+
+List locked = Book.findAll(
+ "from Book b where b.genre = :genre",
+ [genre: 'Tech'],
+ [lock: true])
----
+When `lock: true` is used, GORM requests a pessimistic write lock and disables query caching for that query.
+
=== Bulk Updates and Deletes
[source,groovy]
diff --git a/grails-doc/src/en/ref/Domain Classes/executeQuery.adoc b/grails-doc/src/en/ref/Domain Classes/executeQuery.adoc
index f6c1cb1286..74e6d4f0c9 100644
--- a/grails-doc/src/en/ref/Domain Classes/executeQuery.adoc
+++ b/grails-doc/src/en/ref/Domain Classes/executeQuery.adoc
@@ -76,7 +76,15 @@ Account.executeQuery("select distinct a.number from Account a",
// modify the FlushMode of the Query (default is `FlushMode.AUTO`)
Account.executeQuery("select distinct a.number from Account a",
- null, [flushMode: FlushMode.MANUAL])
+ null, [flushMode: FlushMode.MANUAL])
+
+// enable the query cache when Hibernate query caching is configured
+Account.executeQuery("select distinct a.number from Account a",
+ null, [cache: true])
+
+// request a pessimistic write lock; locked queries are not query-cacheable
+Account.executeQuery("from Account a where a.branch = :branch",
+ [branch: 'London'], [lock: true])
----
@@ -99,4 +107,4 @@ Parameters:
* `query` - An HQL query
* `positionalParams` - A `List` of parameters for a positional parameterized query
* `namedParams` - A `Map` of named parameters for a named parameterized query
-* `metaParams` - A `Map` of pagination parameters `max` or/and `offset`, as well as Hibernate query parameters `readOnly`, `fetchSize`, `timeout`, and `flushMode`
+* `metaParams` - A `Map` of pagination parameters `max` and/or `offset`, as well as Hibernate query parameters `readOnly`, `fetchSize`, `timeout`, `flushMode`, `cache`, and `lock`
diff --git a/grails-doc/src/en/ref/Domain Classes/find.adoc b/grails-doc/src/en/ref/Domain Classes/find.adoc
index da7192da4d..220065de3b 100644
--- a/grails-doc/src/en/ref/Domain Classes/find.adoc
+++ b/grails-doc/src/en/ref/Domain Classes/find.adoc
@@ -78,5 +78,5 @@ Parameters:
* `query` - An HQL query
* `positionalParams` - A `List` of parameters for a positional parametrized HQL query
* `namedParams` - A `Map` of named parameters a HQL query
-* `queryParams` - A `Map` of query parameters. Currently, only `cache` is supported
+* `queryParams` - A `Map` of query parameters such as `cache`, `readOnly`, `fetchSize`, `timeout`, `flushMode`, and `lock`
* `example` - An instance of the domain class for query by example
diff --git a/grails-doc/src/en/ref/Domain Classes/findAll.adoc b/grails-doc/src/en/ref/Domain Classes/findAll.adoc
index 0e9ae24d44..7d7724fbda 100644
--- a/grails-doc/src/en/ref/Domain Classes/findAll.adoc
+++ b/grails-doc/src/en/ref/Domain Classes/findAll.adoc
@@ -119,9 +119,10 @@ Parameters:
* `query` - An HQL query
* `positionalParams` - A `List` of parameters for a positional parametrized HQL query
* `namedParams` - A `Map` of named parameters a HQL query
-* `queryParams` - A `Map` containing parameters 'max', and/or 'offset' and/or 'cache'
+* `queryParams` - A `Map` containing parameters `max`, `offset`, `cache`, and other supported query settings
* `example` - An instance of the domain class for query by example
* `readOnly` - `true` if returned objects should not be automatically dirty-checked (simlar to `read()`)
* `fetchSize` - number of rows fetched by the underlying JDBC driver per round trip
* `flushMode` - Hibernate `FlushMode` override, defaults to `FlushMode.AUTO`
* `timeout` - query timeout in seconds
+* `lock` - `true` to request a pessimistic write lock; locked queries are not query-cacheable