You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by bo...@apache.org on 2026/04/10 16:41:15 UTC
(grails-core) branch 8.0.x-hibernate7-dev updated (939e5ea93d -> 63f9a06f6d)
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a change to branch 8.0.x-hibernate7-dev
in repository https://gitbox.apache.org/repos/asf/grails-core.git
from 939e5ea93d fix: address Copilot PR review comments
new 3deb60a5bf fix bytebuddy
new c0d2d3e89e fix testcontainers versions
new 1c505d5cf0 fix broken dbmigration tests
new 63f9a06f6d H7 increase test coverge
The 4 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.
Summary of changes:
dependencies.gradle | 4 +-
grails-data-hibernate7/core/build.gradle | 20 +-
.../orm/HibernateCriteriaBuilderDirectSpec.groovy | 420 +++++++++++++++++++++
.../orm/hibernate/HibernateDatastoreSpec.groovy | 103 +++++
.../hibernate/SchemaTenantGormEnhancerSpec.groovy | 24 +-
grails-data-hibernate7/dbmigration/build.gradle | 4 +-
.../integration-test/resources/logback-test.xml | 36 ++
.../DbmGenerateGormChangelogCommandSpec.groovy | 8 +-
.../command/DbmGormDiffCommandSpec.groovy | 8 +-
grails-data-mongodb/core/build.gradle | 2 +-
grails-forge/grails-forge-cli/build.gradle | 2 +-
11 files changed, 598 insertions(+), 33 deletions(-)
(grails-core) 02/04: fix testcontainers versions
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit c0d2d3e89edbdf71c1314dad4dbe2c9a7c7912c0
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Fri Apr 10 10:34:02 2026 -0500
fix testcontainers versions
---
dependencies.gradle | 2 +-
grails-data-hibernate7/core/build.gradle | 18 +++++++++---------
grails-data-hibernate7/dbmigration/build.gradle | 4 ++--
grails-data-mongodb/core/build.gradle | 2 +-
grails-forge/grails-forge-cli/build.gradle | 2 +-
5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/dependencies.gradle b/dependencies.gradle
index 061b88f5a0..59898d1c9f 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -38,7 +38,7 @@ ext {
'jquery.version' : '3.7.1',
'objenesis.version' : '3.4',
'spring-boot.version' : '4.0.5',
- 'testcontainers.version' : '1.20.1',
+ 'testcontainers.version' : '2.0.4',
]
// Note: the name of the dependency must be the prefix of the property name so properties in the pom are resolved correctly
diff --git a/grails-data-hibernate7/core/build.gradle b/grails-data-hibernate7/core/build.gradle
index 07bc620e57..8c5eb861ce 100644
--- a/grails-data-hibernate7/core/build.gradle
+++ b/grails-data-hibernate7/core/build.gradle
@@ -87,15 +87,15 @@ dependencies {
}
testImplementation 'org.testcontainers:testcontainers'
- testImplementation 'org.postgresql:postgresql:42.7.5'
- testImplementation 'org.testcontainers:postgresql'
- testImplementation 'com.mysql:mysql-connector-j:9.2.0'
- testImplementation 'org.testcontainers:mysql'
- testImplementation 'org.mariadb.jdbc:mariadb-java-client:3.5.2'
- testImplementation 'org.testcontainers:mariadb'
- testImplementation 'com.oracle.database.jdbc:ojdbc11:23.7.0.25.01'
- testImplementation 'org.testcontainers:oracle-free'
- testImplementation 'org.testcontainers:spock'
+ testImplementation 'org.postgresql:postgresql'
+ testImplementation 'org.testcontainers:testcontainers-postgresql'
+ testImplementation 'com.mysql:mysql-connector-j'
+ testImplementation 'org.testcontainers:testcontainers-mysql'
+ testImplementation 'org.mariadb.jdbc:mariadb-java-client'
+ testImplementation 'org.testcontainers:testcontainers-mariadb'
+ testImplementation 'com.oracle.database.jdbc:ojdbc11'
+ testImplementation 'org.testcontainers:testcontainers-oracle-free'
+ testImplementation 'org.testcontainers:testcontainers-spock'
testImplementation 'org.jsr107.ri:cache-ri-impl:1.1.1'
testImplementation 'org.objenesis:objenesis:3.4' // or a more recent version if available
diff --git a/grails-data-hibernate7/dbmigration/build.gradle b/grails-data-hibernate7/dbmigration/build.gradle
index 2e08d24678..a5d2573b56 100644
--- a/grails-data-hibernate7/dbmigration/build.gradle
+++ b/grails-data-hibernate7/dbmigration/build.gradle
@@ -87,8 +87,8 @@ dependencies {
testImplementation project(':grails-testing-support-web')
testImplementation 'org.testcontainers:testcontainers'
- testImplementation 'org.testcontainers:postgresql'
- testImplementation 'org.testcontainers:spock'
+ testImplementation 'org.testcontainers:testcontainers-postgresql'
+ testImplementation 'org.testcontainers:testcontainers-spock'
testImplementation 'com.h2database:h2'
testImplementation 'org.hsqldb:hsqldb'
testImplementation 'org.postgresql:postgresql'
diff --git a/grails-data-mongodb/core/build.gradle b/grails-data-mongodb/core/build.gradle
index d244c24b52..c2c7b49d5c 100644
--- a/grails-data-mongodb/core/build.gradle
+++ b/grails-data-mongodb/core/build.gradle
@@ -133,7 +133,7 @@ dependencies {
testImplementation 'org.testcontainers:testcontainers'
testImplementation 'org.testcontainers:mongodb'
- testImplementation 'org.testcontainers:spock'
+ testImplementation 'org.testcontainers:testcontainers-spock'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testRuntimeOnly 'org.slf4j:slf4j-nop' // Get rid of warning about missing slf4j implementation during tests
diff --git a/grails-forge/grails-forge-cli/build.gradle b/grails-forge/grails-forge-cli/build.gradle
index b44a145b51..2fe5810e0f 100644
--- a/grails-forge/grails-forge-cli/build.gradle
+++ b/grails-forge/grails-forge-cli/build.gradle
@@ -97,7 +97,7 @@ dependencies {
testImplementation 'io.micronaut.picocli:micronaut-picocli'
testImplementation "org.reflections:reflections:$reflectionsVersion"
- testImplementation 'org.testcontainers:spock'
+ testImplementation 'org.testcontainers:testcontainers-spock'
if (project.hasProperty('micronautVersion')) {
testCompileOnly "io.micronaut:micronaut-inject-groovy:$micronautVersion"
}
(grails-core) 03/04: fix broken dbmigration tests
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 1c505d5cf0ff150eb78eede7006d14ffb580bf83
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Fri Apr 10 11:32:46 2026 -0500
fix broken dbmigration tests
---
.../integration-test/resources/logback-test.xml | 36 ++++++++++++++++++++++
.../DbmGenerateGormChangelogCommandSpec.groovy | 8 ++---
.../command/DbmGormDiffCommandSpec.groovy | 8 ++---
3 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/grails-data-hibernate7/dbmigration/src/integration-test/resources/logback-test.xml b/grails-data-hibernate7/dbmigration/src/integration-test/resources/logback-test.xml
index e69de29bb2..1576e5585e 100644
--- a/grails-data-hibernate7/dbmigration/src/integration-test/resources/logback-test.xml
+++ b/grails-data-hibernate7/dbmigration/src/integration-test/resources/logback-test.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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
+
+ http://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.
+
+-->
+<configuration>
+
+ <conversionRule conversionWord="clr" class="org.springframework.boot.logging.logback.ColorConverter" />
+ <conversionRule conversionWord="wex" class="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <charset>UTF-8</charset>
+ <pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex</pattern>
+ </encoder>
+ </appender>
+
+ <root level="ERROR"><appender-ref ref="STDOUT"/></root>
+
+</configuration>
diff --git a/grails-data-hibernate7/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy b/grails-data-hibernate7/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy
index e7a075146d..34124ea6eb 100644
--- a/grails-data-hibernate7/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy
+++ b/grails-data-hibernate7/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy
@@ -62,11 +62,11 @@ databaseChangeLog = \\{
constraints\\(nullable: "false"\\)
\\}
- column\\(name: "author_id", type: "BIGINT"\\) \\{
+ column\\(name: "title", type: "VARCHAR\\(255\\)"\\) \\{
constraints\\(nullable: "false"\\)
\\}
- column\\(name: "title", type: "VARCHAR\\(255\\)"\\) \\{
+ column\\(name: "author_id", type: "BIGINT"\\) \\{
constraints\\(nullable: "false"\\)
\\}
\\}
@@ -117,11 +117,11 @@ databaseChangeLog = \\{
constraints\\(nullable: "false"\\)
\\}
- column\\(name: "author_id", type: "BIGINT"\\) \\{
+ column\\(name: "title", type: "VARCHAR\\(255\\)"\\) \\{
constraints\\(nullable: "false"\\)
\\}
- column\\(name: "title", type: "VARCHAR\\(255\\)"\\) \\{
+ column\\(name: "author_id", type: "BIGINT"\\) \\{
constraints\\(nullable: "false"\\)
\\}
\\}
diff --git a/grails-data-hibernate7/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy b/grails-data-hibernate7/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy
index 841996094a..c5354bbc2f 100644
--- a/grails-data-hibernate7/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy
+++ b/grails-data-hibernate7/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy
@@ -50,11 +50,11 @@ databaseChangeLog = \\{
constraints\\(nullable: "false"\\)
\\}
- column\\(name: "author_id", type: "BIGINT"\\) \\{
+ column\\(name: "title", type: "VARCHAR\\(255\\)"\\) \\{
constraints\\(nullable: "false"\\)
\\}
- column\\(name: "title", type: "VARCHAR\\(255\\)"\\) \\{
+ column\\(name: "author_id", type: "BIGINT"\\) \\{
constraints\\(nullable: "false"\\)
\\}
\\}
@@ -89,11 +89,11 @@ databaseChangeLog = \\{
constraints\\(nullable: "false"\\)
\\}
- column\\(name: "author_id", type: "BIGINT"\\) \\{
+ column\\(name: "title", type: "VARCHAR\\(255\\)"\\) \\{
constraints\\(nullable: "false"\\)
\\}
- column\\(name: "title", type: "VARCHAR\\(255\\)"\\) \\{
+ column\\(name: "author_id", type: "BIGINT"\\) \\{
constraints\\(nullable: "false"\\)
\\}
\\}
(grails-core) 04/04: H7 increase test coverge
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 63f9a06f6ddb9c5e83cd38f04219d139b2ff24af
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Fri Apr 10 11:40:57 2026 -0500
H7 increase test coverge
---
.../orm/HibernateCriteriaBuilderDirectSpec.groovy | 420 +++++++++++++++++++++
.../orm/hibernate/HibernateDatastoreSpec.groovy | 103 +++++
.../hibernate/SchemaTenantGormEnhancerSpec.groovy | 24 +-
3 files changed, 538 insertions(+), 9 deletions(-)
diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/orm/HibernateCriteriaBuilderDirectSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/orm/HibernateCriteriaBuilderDirectSpec.groovy
index 150708291c..9f93d71ba7 100644
--- a/grails-data-hibernate7/core/src/test/groovy/grails/orm/HibernateCriteriaBuilderDirectSpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/grails/orm/HibernateCriteriaBuilderDirectSpec.groovy
@@ -290,6 +290,426 @@ class HibernateCriteriaBuilderDirectSpec extends HibernateGormDatastoreSpec {
results[0].firstName == "Fred"
}
+ void "test properties and projections methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+
+ then:
+ b.property("firstName")
+ b.distinct("lastName")
+ b.avg("balance")
+ b.projections() != null
+ b.closeSession()
+ }
+
+ void "test boolean flags and setter getter methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.uniqueResult = true
+ b.distinct = true
+ b.count = true
+ b.paginationEnabledList = true
+ b.scroll = true
+
+ then:
+ b.isUniqueResult() == true
+ b.isDistinct() == true
+ b.isCount() == true
+ b.isPaginationEnabledList() == true
+ b.isScroll() == true
+ b.getInstance() == null
+ b.getCriteriaBuilder() != null
+ b.getSessionFactory() != null
+ b.getHibernateQuery() != null
+ b.isParticipate() == true
+ b.getDefaultFlushMode() == org.grails.orm.hibernate.GrailsHibernateTemplate.FLUSH_AUTO
+
+ when:
+ b.setDefaultFlushMode(1)
+ then:
+ b.getDefaultFlushMode() == 1
+
+ when:
+ b.lock(true)
+ b.cache(true)
+ b.maxResults(10)
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test alias and join methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.join("transactions")
+ b.join("transactions", jakarta.persistence.criteria.JoinType.INNER)
+ b.select("transactions")
+ b.createAlias("transactions", "t")
+ b.createAlias("transactions", "t2", 1) // LEFT
+ b.createAlias("transactions", "t3", 2) // RIGHT
+ b.createAlias("transactions", "t4", 3) // INNER
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test exception handling"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.throwRuntimeException(new RuntimeException("test exception"))
+
+ then:
+ thrown(RuntimeException)
+ }
+
+ void "test missing criterion methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.eqProperty("firstName", "lastName")
+ b.neProperty("firstName", "lastName")
+ b.gtProperty("firstName", "lastName")
+ b.geProperty("firstName", "lastName")
+ b.ltProperty("firstName", "lastName")
+ b.leProperty("firstName", "lastName")
+
+ b.allEq(["firstName": "Fred"])
+ b.idEq(1L)
+ b.idEquals(1L)
+
+ b.isEmpty("firstName")
+ b.isNotEmpty("firstName")
+ b.isNull("firstName")
+ b.isNotNull("firstName")
+
+ b.like("firstName", "Fre%")
+ b.ilike("firstName", "fre%")
+ b.rlike("firstName", ".*")
+
+ b.in("firstName", ["Fred", "Barney"])
+ b.inList("firstName", ["Fred", "Barney"])
+ b.inList("firstName", "Fred", "Barney")
+ b.in("firstName", "Fred", "Barney")
+ b.notIn("firstName") { eq("firstName", "Wilma") }
+
+ b.gt("balance", 100)
+ b.ge("balance", 100)
+ b.gte("balance", 100)
+ b.lt("balance", 100)
+ b.le("balance", 100)
+ b.lte("balance", 100)
+ b.ne("balance", 100)
+ b.between("balance", 100, 200)
+
+ b.sizeEq("transactions", 1)
+ b.sizeGt("transactions", 1)
+ b.sizeGe("transactions", 1)
+ b.sizeLt("transactions", 1)
+ b.sizeLe("transactions", 1)
+ b.sizeNe("transactions", 1)
+
+ b.order("firstName")
+ b.order("lastName", "desc")
+ b.firstResult(0)
+
+ b.and { eq("firstName", "Fred") }
+ b.or { eq("firstName", "Fred") }
+ b.not { eq("firstName", "Fred") }
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test subqueries with closures"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+
+ b.eqAll("balance") { eq("balance", 100) }
+ b.gtAll("balance") { eq("balance", 100) }
+ b.geAll("balance") { eq("balance", 100) }
+ b.ltAll("balance") { eq("balance", 100) }
+ b.leAll("balance") { eq("balance", 100) }
+
+ b.gtSome("balance") { eq("balance", 100) }
+ b.geSome("balance") { eq("balance", 100) }
+ b.ltSome("balance") { eq("balance", 100) }
+ b.leSome("balance") { eq("balance", 100) }
+
+ b.in("balance") { eq("balance", 100) }
+ b.inList("balance") { eq("balance", 100) }
+ b.notIn("balance") { eq("balance", 100) }
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test subqueries with QueryableCriteria"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ def criteria = new grails.gorm.DetachedCriteria(DirectAccount).build { eq("balance", 100) }
+
+ b.eqAll("balance", criteria)
+ b.gtAll("balance", criteria)
+ b.geAll("balance", criteria)
+ b.ltAll("balance", criteria)
+ b.leAll("balance", criteria)
+
+ b.gtSome("balance", criteria)
+ b.geSome("balance", criteria)
+ b.ltSome("balance", criteria)
+ b.leSome("balance", criteria)
+
+ b.in("balance", criteria)
+ b.inList("balance", criteria)
+ b.notIn("balance", criteria)
+
+ b.exists(criteria)
+ b.notExists(criteria)
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test execution methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.list { eq("firstName", "Fred") }
+ b.list([max: 10]) { eq("firstName", "Fred") }
+ b.listDistinct { eq("firstName", "Fred") }
+ b.get { eq("firstName", "Fred") }
+ try { b.scroll { eq("firstName", "Fred") } } catch(UnsupportedOperationException e) { /* expected in this mock environment */ }
+ b.list()
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test properties and projections methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+
+ then:
+ b.property("firstName")
+ b.distinct("lastName")
+ b.avg("balance")
+ b.projections() != null
+ b.closeSession()
+ }
+
+ void "test boolean flags and setter getter methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.uniqueResult = true
+ b.distinct = true
+ b.count = true
+ b.paginationEnabledList = true
+ b.scroll = true
+
+ then:
+ b.isUniqueResult() == true
+ b.isDistinct() == true
+ b.isCount() == true
+ b.isPaginationEnabledList() == true
+ b.isScroll() == true
+ b.getInstance() == null
+ b.getCriteriaBuilder() != null
+ b.getSessionFactory() != null
+ b.getHibernateQuery() != null
+ b.isParticipate() == true
+ b.getDefaultFlushMode() == org.grails.orm.hibernate.GrailsHibernateTemplate.FLUSH_AUTO
+
+ when:
+ b.setDefaultFlushMode(1)
+ then:
+ b.getDefaultFlushMode() == 1
+
+ when:
+ b.lock(true)
+ b.cache(true)
+ b.maxResults(10)
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test alias and join methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.join("transactions")
+ b.join("transactions", jakarta.persistence.criteria.JoinType.INNER)
+ b.select("transactions")
+ b.createAlias("transactions", "t")
+ b.createAlias("transactions", "t2", 1) // LEFT
+ b.createAlias("transactions", "t3", 2) // RIGHT
+ b.createAlias("transactions", "t4", 3) // INNER
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test exception handling"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.throwRuntimeException(new RuntimeException("test exception"))
+
+ then:
+ thrown(RuntimeException)
+ }
+
+ void "test missing criterion methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.eqProperty("firstName", "lastName")
+ b.neProperty("firstName", "lastName")
+ b.gtProperty("firstName", "lastName")
+ b.geProperty("firstName", "lastName")
+ b.ltProperty("firstName", "lastName")
+ b.leProperty("firstName", "lastName")
+
+ b.allEq(["firstName": "Fred"])
+ b.idEq(1L)
+ b.idEquals(1L)
+
+ b.isEmpty("firstName")
+ b.isNotEmpty("firstName")
+ b.isNull("firstName")
+ b.isNotNull("firstName")
+
+ b.like("firstName", "Fre%")
+ b.ilike("firstName", "fre%")
+ b.rlike("firstName", ".*")
+
+ b.in("firstName", ["Fred", "Barney"])
+ b.inList("firstName", ["Fred", "Barney"])
+ b.inList("firstName", "Fred", "Barney")
+ b.in("firstName", "Fred", "Barney")
+ b.notIn("firstName") { eq("firstName", "Wilma") }
+
+ b.gt("balance", 100)
+ b.ge("balance", 100)
+ b.gte("balance", 100)
+ b.lt("balance", 100)
+ b.le("balance", 100)
+ b.lte("balance", 100)
+ b.ne("balance", 100)
+ b.between("balance", 100, 200)
+
+ b.sizeEq("transactions", 1)
+ b.sizeGt("transactions", 1)
+ b.sizeGe("transactions", 1)
+ b.sizeLt("transactions", 1)
+ b.sizeLe("transactions", 1)
+ b.sizeNe("transactions", 1)
+
+ b.order("firstName")
+ b.order("lastName", "desc")
+ b.firstResult(0)
+
+ b.and { eq("firstName", "Fred") }
+ b.or { eq("firstName", "Fred") }
+ b.not { eq("firstName", "Fred") }
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test subqueries with closures"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+
+ b.eqAll("balance") { eq("balance", 100) }
+ b.gtAll("balance") { eq("balance", 100) }
+ b.geAll("balance") { eq("balance", 100) }
+ b.ltAll("balance") { eq("balance", 100) }
+ b.leAll("balance") { eq("balance", 100) }
+
+ b.gtSome("balance") { eq("balance", 100) }
+ b.geSome("balance") { eq("balance", 100) }
+ b.ltSome("balance") { eq("balance", 100) }
+ b.leSome("balance") { eq("balance", 100) }
+
+ b.in("balance") { eq("balance", 100) }
+ b.inList("balance") { eq("balance", 100) }
+ b.notIn("balance") { eq("balance", 100) }
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test subqueries with QueryableCriteria"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ def criteria = new grails.gorm.DetachedCriteria(DirectAccount).build { eq("balance", 100) }
+
+ b.eqAll("balance", criteria)
+ b.gtAll("balance", criteria)
+ b.geAll("balance", criteria)
+ b.ltAll("balance", criteria)
+ b.leAll("balance", criteria)
+
+ b.gtSome("balance", criteria)
+ b.geSome("balance", criteria)
+ b.ltSome("balance", criteria)
+ b.leSome("balance", criteria)
+
+ b.in("balance", criteria)
+ b.inList("balance", criteria)
+ b.notIn("balance", criteria)
+
+ b.exists(criteria)
+ b.notExists(criteria)
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
+ void "test execution methods"() {
+ when:
+ def b = new HibernateCriteriaBuilder(DirectAccount, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+ b.list { eq("firstName", "Fred") }
+ b.list([max: 10]) { eq("firstName", "Fred") }
+ b.listDistinct { eq("firstName", "Fred") }
+ b.get { eq("firstName", "Fred") }
+ try { b.scroll { eq("firstName", "Fred") } } catch(UnsupportedOperationException e) { /* expected in this mock environment */ }
+ b.list()
+
+ then:
+ noExceptionThrown()
+
+ cleanup:
+ b.closeSession()
+ }
+
// ─── Comparison predicates ─────────────────────────────────────────────
def "eq(String, Object) delegates and returns this"() {
diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreSpec.groovy
index f792084283..9a2a9302bd 100644
--- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreSpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreSpec.groovy
@@ -248,6 +248,109 @@ class HibernateDatastoreSpec extends HibernateGormDatastoreSpec {
expect:
datastore.getMetadata() != null
}
+
+ void "test toString returns datasource name"() {
+ expect:
+ datastore.toString() == "HibernateDatastore: default"
+ }
+
+ void "test withSession and withNewSession for connectionName"() {
+ when:
+ def result1 = datastore.withSession("default") { session -> return "session1" }
+ def result2 = datastore.withNewSession("default") { session -> return "session2" }
+
+ then:
+ result1 == "session1"
+ result2 == "session2"
+ }
+
+ void "test withNewSession with tenantId for non-DATABASE multitenancy"() {
+ when:
+ def result = datastore.withNewSession((Serializable) "someTenant") { session -> return "sessionTenant" }
+
+ then:
+ result == "sessionTenant"
+ }
+
+ void "test close handles exception"() {
+ given:
+ def ds = new HibernateDatastore(Collections.singletonMap(Settings.SETTING_DB_CREATE, "create-drop"), GHUBook) {
+ @Override
+ void destroy() throws Exception {
+ throw new RuntimeException("destroy failed")
+ }
+ }
+
+ when:
+ ds.close()
+
+ then:
+ noExceptionThrown()
+ }
+
+ void "test constructors"() {
+ given:
+ def configMap = new HashMap<>(manager.grailsConfig)
+ configMap.put("dataSource.url", "jdbc:h2:mem:grailsDB-constructors;LOCK_TIMEOUT=10000") // avoid clash with datastore
+ org.springframework.core.env.PropertyResolver propertyResolver = org.grails.datastore.mapping.core.DatastoreUtils.createPropertyResolver(configMap)
+ def dataSource = datastore.dataSource
+ def eventPublisher = datastore.applicationEventPublisher as org.grails.datastore.gorm.events.ConfigurableApplicationEventPublisher
+ Package pkg = String.getPackage()
+
+ when: "Constructor with EventPublisher and Classes"
+ def ds1 = new HibernateDatastore(propertyResolver, eventPublisher, GHUBook)
+ then:
+ ds1 != null
+ ds1.close()
+
+ when: "Constructor with DataSource, EventPublisher and Classes"
+ def ds2 = new HibernateDatastore(dataSource, propertyResolver, eventPublisher, GHUBook)
+ then:
+ ds2 != null
+ ds2.close()
+
+ when: "Constructor with EventPublisher and Packages"
+ def ds3 = new HibernateDatastore(propertyResolver, eventPublisher, pkg)
+ then:
+ ds3 != null
+ ds3.close()
+
+ when: "Constructor with DataSource, EventPublisher and Packages"
+ def ds4 = new HibernateDatastore(dataSource, propertyResolver, eventPublisher, pkg)
+ then:
+ ds4 != null
+ ds4.close()
+
+ when: "Constructor with Configuration Map and Packages"
+ def ds5 = new HibernateDatastore(configMap, pkg)
+ then:
+ ds5 != null
+ ds5.close()
+
+ when: "Constructor with Packages only"
+ def ds6 = new HibernateDatastore(pkg)
+ then:
+ ds6 != null
+ ds6.close()
+
+ when: "Constructor with MappingContext, SessionFactory, PropertyResolver, ApplicationContext, dataSourceName"
+ def ds7 = new HibernateDatastore(datastore.mappingContext, datastore.sessionFactory, propertyResolver, datastore.applicationContext, "default")
+ then:
+ ds7 != null
+
+ when: "Constructor with MappingContext, SessionFactory, PropertyResolver"
+ def ds8 = new HibernateDatastore(datastore.mappingContext, datastore.sessionFactory, propertyResolver)
+ then:
+ ds8 != null
+ }
+
+ void "test setMessageSource"() {
+ when:
+ datastore.setMessageSource(Mock(org.springframework.context.MessageSource))
+
+ then:
+ noExceptionThrown()
+ }
}
@Entity
diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/SchemaTenantGormEnhancerSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/SchemaTenantGormEnhancerSpec.groovy
index c7b7565d94..487ed0ffc6 100644
--- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/SchemaTenantGormEnhancerSpec.groovy
+++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/SchemaTenantGormEnhancerSpec.groovy
@@ -32,7 +32,7 @@ import spock.lang.Shared
import spock.lang.Specification
/**
- * Verifies the behaviour of {@link HibernateDatastore.SchemaTenantGormEnhancer}
+ * Verifies the behaviour of SchemaTenantGormEnhancer
* which is instantiated when the datastore runs in SCHEMA multi-tenancy mode.
*
* Because Hibernate infrastructure classes are final / sealed, we drive the
@@ -45,7 +45,7 @@ class SchemaTenantGormEnhancerSpec extends Specification {
HibernateDatastore datastore
@Shared
- HibernateDatastore.SchemaTenantGormEnhancer enhancer
+ def enhancer
void setupSpec() {
System.setProperty(SystemPropertyTenantResolver.PROPERTY_NAME, "")
@@ -60,7 +60,7 @@ class SchemaTenantGormEnhancerSpec extends Specification {
'hibernate.hbm2ddl.auto' : 'create',
]
datastore = new HibernateDatastore(DatastoreUtils.createPropertyResolver(config), SchemaTenantBook)
- enhancer = datastore.gormEnhancer as HibernateDatastore.SchemaTenantGormEnhancer
+ enhancer = datastore.gormEnhancer
}
void cleanupSpec() {
@@ -70,7 +70,7 @@ class SchemaTenantGormEnhancerSpec extends Specification {
void "gormEnhancer is an instance of SchemaTenantGormEnhancer in SCHEMA mode"() {
expect:
- enhancer instanceof HibernateDatastore.SchemaTenantGormEnhancer
+ enhancer.getClass().name == "org.grails.orm.hibernate.HibernateDatastore\$SchemaTenantGormEnhancer"
}
void "allQualifiers includes tenant IDs from AllTenantsResolver for MultiTenant entity"() {
@@ -112,15 +112,21 @@ class SchemaTenantGormEnhancerSpec extends Specification {
}
void "SchemaTenantGormEnhancer is a public static nested class of HibernateDatastore"() {
+ given:
+ def enhancerClass = Class.forName("org.grails.orm.hibernate.HibernateDatastore\$SchemaTenantGormEnhancer")
+
expect:
- HibernateDatastore.SchemaTenantGormEnhancer.enclosingClass == HibernateDatastore
- Modifier.isStatic(HibernateDatastore.SchemaTenantGormEnhancer.modifiers)
- Modifier.isPublic(HibernateDatastore.SchemaTenantGormEnhancer.modifiers)
+ enhancerClass.enclosingClass == HibernateDatastore
+ Modifier.isStatic(enhancerClass.modifiers)
+ Modifier.isPublic(enhancerClass.modifiers)
}
void "SchemaTenantGormEnhancer extends HibernateGormEnhancer"() {
+ given:
+ def enhancerClass = Class.forName("org.grails.orm.hibernate.HibernateDatastore\$SchemaTenantGormEnhancer")
+
expect:
- HibernateGormEnhancer.isAssignableFrom(HibernateDatastore.SchemaTenantGormEnhancer)
+ HibernateGormEnhancer.isAssignableFrom(enhancerClass)
}
// -------------------------------------------------------------------------
@@ -142,7 +148,7 @@ class SchemaTenantGormEnhancerSpec extends Specification {
]
HibernateDatastore schemaDs = new HibernateDatastore(
DatastoreUtils.createPropertyResolver(config), SchemaTenantBook)
- def schemaEnhancer = schemaDs.gormEnhancer as HibernateDatastore.SchemaTenantGormEnhancer
+ def schemaEnhancer = schemaDs.gormEnhancer
def entity = schemaDs.getMappingContext().getPersistentEntity(SchemaTenantBook.name)
when: "allQualifiers resolves via schemaHandler (H2 returns no custom schemas)"
(grails-core) 01/04: fix bytebuddy
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 3deb60a5bf22e0831a7209060679b0cdeee6aa2a
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Fri Apr 10 09:05:14 2026 -0500
fix bytebuddy
---
dependencies.gradle | 2 +-
grails-data-hibernate7/core/build.gradle | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dependencies.gradle b/dependencies.gradle
index 00fb089554..061b88f5a0 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -26,7 +26,7 @@ ext {
'asciidoctor-gradle-jvm.version': '4.0.5',
'asciidoctorj.version' : '3.0.0',
'asset-pipeline-gradle.version' : '5.1.0-M4',
- 'byte-buddy.version' : '1.17.8',
+ 'byte-buddy.version' : '1.18.7',
'commons-text.version' : '1.14.0',
'directory-watcher.version' : '0.19.1',
'gradle-spock.version' : '2.3-groovy-3.0',
diff --git a/grails-data-hibernate7/core/build.gradle b/grails-data-hibernate7/core/build.gradle
index 98b5d30d18..07bc620e57 100644
--- a/grails-data-hibernate7/core/build.gradle
+++ b/grails-data-hibernate7/core/build.gradle
@@ -48,7 +48,7 @@ dependencies {
api 'org.springframework:spring-orm'
compileOnly 'org.springframework:spring-webmvc'
compileOnly 'jakarta.servlet:jakarta.servlet-api'
- implementation "net.bytebuddy:byte-buddy:1.18.7"
+ implementation 'net.bytebuddy:byte-buddy'
api "org.hibernate.orm:hibernate-core:$hibernate7Version", {
exclude group:'commons-logging', module:'commons-logging'
exclude group:'com.h2database', module:'h2'