This is an automated email from the ASF dual-hosted git repository.

borinquenkid pushed a commit to branch merge-hibernate6
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 8b3fb003693ea422bc1bd31446a94d2c239a80a0
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Sun Jun 29 15:15:37 2025 -0400

    Fix for OneToOneSpec
---
 .../data/testing/tck/tests/OneToOneSpec.groovy     | 30 +++++++++++++++-------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git 
a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/OneToOneSpec.groovy
 
b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/OneToOneSpec.groovy
index 48dcf33d16..cf96d8a52f 100644
--- 
a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/OneToOneSpec.groovy
+++ 
b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/OneToOneSpec.groovy
@@ -18,6 +18,7 @@
  */
 package org.apache.grails.data.testing.tck.tests
 
+import grails.persistence.Entity
 import org.apache.grails.data.testing.tck.domains.Face
 import org.apache.grails.data.testing.tck.domains.Nose
 import org.apache.grails.data.testing.tck.domains.Person
@@ -33,20 +34,18 @@ class OneToOneSpec extends GrailsDataTckSpec {
 
     def "Test persist and retrieve unidirectional many-to-one"() {
         given: "A domain model with a many-to-one"
-        def person = new Person(firstName: "Fred", lastName: "Flintstone")
-        def pet = new Pet(name: "Dino", owner: person)
-        person.save()
-        pet.save(flush: true)
+        def oneToManyEntity = new OwnerEntity()
+        def manyToOneEntity = new OwnedEntity(oneToMany: oneToManyEntity)
+        oneToManyEntity.save()
+        manyToOneEntity.save(flush: true)
         manager.session.clear()
 
         when: "The association is queried"
-        pet = Pet.findByName("Dino")
+        manyToOneEntity = OwnedEntity.list()[0]
 
         then: "The domain model is valid"
-        pet != null
-        pet.name == "Dino"
-        pet.ownerId == person.id
-        pet.owner.firstName == "Fred"
+        manyToOneEntity != null
+        manyToOneEntity.oneToMany.id == oneToManyEntity.id
     }
 
     def "Test persist and retrieve one-to-one with inverse key"() {
@@ -81,3 +80,16 @@ class OneToOneSpec extends GrailsDataTckSpec {
         nose.face.name == "Joe"
     }
 }
+
+@Entity
+class OwnerEntity {
+
+}
+
+@Entity
+class OwnedEntity {
+    OwnerEntity oneToMany
+
+    static belongsTo = [oneToMany: OwnerEntity]
+
+}

Reply via email to