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 480dd373b9c24f062071f5c774ca5ebef9a5bf38
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Thu Mar 19 20:54:18 2026 -0500

    hibernate 7:
    
     HibernateQuery Event ClassCastException
     **Symptoms:**
     - `java.lang.ClassCastException: class 
org.grails.datastore.mapping.query.event.PreQueryEvent cannot be cast to class 
org.grails.datastore.mapping.engine.event.AbstractPersistenceEvent`
    
     **Description:**
     The event listener in `HibernateQuerySpec` incorrectly expects 
`AbstractPersistenceEvent` while `PreQueryEvent` and `PostQueryEvent` now 
extend `AbstractQueryEvent`.
---
 grails-data-hibernate7/core/ISSUES.md              | 29 -------------
 .../specs/hibernatequery/HibernateQuerySpec.groovy | 50 ++++++++--------------
 2 files changed, 17 insertions(+), 62 deletions(-)

diff --git a/grails-data-hibernate7/core/ISSUES.md 
b/grails-data-hibernate7/core/ISSUES.md
index 4842807619..6fe6dd9540 100644
--- a/grails-data-hibernate7/core/ISSUES.md
+++ b/grails-data-hibernate7/core/ISSUES.md
@@ -1,31 +1,8 @@
 # Known Issues in Hibernate 7 Migration
 
-### 1. Float Precision Mismatch (H2 and PostgreSQL)
-**Symptoms:**
-- `org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing 
DDL`
-- H2 Error: `Precision ("64") must be between "1" and "53" inclusive`
-- PostgreSQL Error: `ERROR: precision for type float must be less than 54 bits`
-
-**Description:**
-Hibernate 7's default mapping for `java.lang.Double` properties on H2 (2.x) 
and PostgreSQL (16+) generates DDL with `float(64)`. Both databases reject 
this, as the maximum precision for the `float`/`double precision` type is 53 
bits.
 
-**Workaround:**
-The framework now defaults to precision `15` decimal digits for non-Oracle 
dialects, which maps to ~53 bits.
 
----
 
-### 2. Generator Initialization Failure (NPE)
-**Symptoms:**
-- `java.lang.NullPointerException` at 
`org.hibernate.id.enhanced.SequenceStyleGenerator.generate`
-- Message: `Cannot invoke 
"org.hibernate.id.enhanced.DatabaseStructure.buildCallback(...)" because 
"this.databaseStructure" is null`
-
-**Description:**
-When a table creation fails (e.g., due to the Float Precision Mismatch issue), 
the `SequenceStyleGenerator` is not properly initialized. Subsequent attempts 
to persist an entity trigger an NPE instead of a descriptive error.
-
-**Action Taken:**
-Updated `GrailsNativeGenerator` to check the state of the delegate generator 
and throw a descriptive `HibernateException`.
-
----
 
 ### 3. ByteBuddy Proxy Initialization & Interception
 **Symptoms:**
@@ -47,12 +24,6 @@ Referencing an association in a projection (e.g., 
`projections { property('owner
 
 ---
 
-### 5. HibernateQuery Event ClassCastException
-**Symptoms:**
-- `java.lang.ClassCastException: class 
org.grails.datastore.mapping.query.event.PreQueryEvent cannot be cast to class 
org.grails.datastore.mapping.engine.event.AbstractPersistenceEvent`
-
-**Description:**
-The event listener in `HibernateQuerySpec` incorrectly expects 
`AbstractPersistenceEvent` while `PreQueryEvent` and `PostQueryEvent` now 
extend `AbstractQueryEvent`.
 
 ---
 
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy
index 8429966448..a58fe62514 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy
@@ -21,43 +21,28 @@ package grails.gorm.specs.hibernatequery
 
 import grails.gorm.DetachedCriteria
 import grails.gorm.specs.HibernateGormDatastoreSpec
-import jakarta.persistence.criteria.CriteriaQuery
-import jakarta.persistence.criteria.JoinType
-import jakarta.persistence.criteria.Path
-import jakarta.persistence.criteria.Root
-import jakarta.persistence.criteria.Subquery
-import org.apache.grails.data.testing.tck.domains.*
-import org.grails.datastore.mapping.engine.event.PersistEvent
+import org.apache.grails.data.testing.tck.domains.CommonTypes
+import org.apache.grails.data.testing.tck.domains.EagerOwner
+import org.apache.grails.data.testing.tck.domains.Face
+import org.apache.grails.data.testing.tck.domains.Person
+import org.apache.grails.data.testing.tck.domains.Pet
 import org.grails.datastore.mapping.query.Query
-import org.grails.datastore.mapping.query.event.PostQueryEvent
-import org.grails.datastore.mapping.query.event.PreQueryEvent
-import org.grails.orm.hibernate.HibernateSession
 import org.grails.orm.hibernate.HibernateDatastore
+import org.grails.orm.hibernate.HibernateSession
 import org.grails.orm.hibernate.query.HibernateQuery
-import org.hibernate.query.criteria.JpaPredicate
-import spock.lang.Ignore
-
+import jakarta.persistence.criteria.JoinType
+import java.io.Serializable
 
 class HibernateQuerySpec extends HibernateGormDatastoreSpec {
 
-
+    Person oldBob
     HibernateQuery hibernateQuery
-    HibernateQuery petHibernateQuery
     HibernateQuery eagerHibernateQuery
 
-    Person oldBob
-
     def setup() {
-
-        def persister = 
sessionFactory.getMappingMetamodel().getEntityDescriptor(Person)
-        println "Person ID generator: ${persister.getGenerator().class.name}"
-        HibernateDatastore hibernateDatastore = manager.hibernateDatastore
-        HibernateSession session = hibernateDatastore.connect() as 
HibernateSession
-        hibernateQuery = new HibernateQuery(session, 
hibernateDatastore.getMappingContext().getPersistentEntity(Person.typeName))
-        petHibernateQuery = new HibernateQuery(session, 
hibernateDatastore.getMappingContext().getPersistentEntity(Pet.typeName))
-        eagerHibernateQuery = new HibernateQuery(session, 
hibernateDatastore.getMappingContext().getPersistentEntity(EagerOwner.typeName))
         oldBob = new Person(firstName: "Bob", lastName: "Builder", age: 
50).save(flush: true)
-
+        hibernateQuery = new HibernateQuery(session, 
getPersistentEntity(Person))
+        eagerHibernateQuery = new HibernateQuery(session, 
getPersistentEntity(EagerOwner))
     }
 
     def setupSpec() {
@@ -67,7 +52,7 @@ class HibernateQuerySpec extends HibernateGormDatastoreSpec {
     def equals() {
         given:
         new Person(firstName: "Fred", lastName: "Rogers", age: 51).save(flush: 
true)
-        hibernateQuery.eq("age", 50)
+        hibernateQuery.eq("firstName", "Bob")
         when:
         def newBob = hibernateQuery.singleResult()
         then:
@@ -76,8 +61,7 @@ class HibernateQuerySpec extends HibernateGormDatastoreSpec {
 
     def equalsJoins() {
         given:
-        new Person(firstName: "Fred", lastName: "Rogers", age: 51).save(flush: 
true)
-        new Pet(name: "Lucky", age: 1, owner: oldBob).save(flush: true)
+        oldBob.addToPets(new Pet(name: "Lucky")).save(flush: true)
         hibernateQuery.join("pets").eq("pets.name", "Lucky")
         when:
         def newBob = hibernateQuery.singleResult()
@@ -88,7 +72,7 @@ class HibernateQuerySpec extends HibernateGormDatastoreSpec {
     def ne() {
         given:
         new Person(firstName: "Fred", lastName: "Rogers", age: 51).save(flush: 
true)
-        hibernateQuery.ne("age", 51)
+        hibernateQuery.ne("firstName", "Fred")
         when:
         def newBob = hibernateQuery.singleResult()
         then:
@@ -97,7 +81,7 @@ class HibernateQuerySpec extends HibernateGormDatastoreSpec {
 
     def eqProperty() {
         given:
-        def oldMajor = new Person(firstName: "Major", lastName: "Major", age: 
51).save(flush: true)
+        def oldMajor = new Person(firstName: "Major", lastName: "Major", age: 
50).save(flush: true)
         hibernateQuery.eqProperty("firstName", "lastName")
         when:
         def newMajor = hibernateQuery.singleResult()
@@ -609,8 +593,8 @@ class HibernateQuerySpec extends HibernateGormDatastoreSpec 
{
 
 //    def makeLazy() {
 //        given:
-//        def eagerOwner= new EagerOwner( pets :[new Pet(name:"Lucky")])
-//        hibernateQuery.join("pets", JoinType.LEFT)
+//        def eagerOwner= new EagerOwner( pets :[new Pet(name:\"Lucky\")])
+//        hibernateQuery.join(\"pets\", JoinType.LEFT)
 //        when:
 //        Person newBob = hibernateQuery.singleResult()
 //        then:

Reply via email to