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/04/02 14:03:24 UTC

(grails-core) 03/04: fix: restore non-hibernate7 test coverage

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

jamesfredley pushed a commit to branch 8.0.x-hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 20131c09035d213b5b55abe281c6f16e9d982d2c
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu Apr 2 09:37:50 2026 -0400

    fix: restore non-hibernate7 test coverage
    
    Restores test coverage for hibernate5, mongodb, and core-test that was
    lost in the 8.0.x-hibernate7 merge.
    
    TCK specs:
    - FindByMethodSpec: restore 16 missing test methods from spring-boot-4
    - OptimisticLockingSpec: add withNewSession-based tests for mongodb
      (matching spring-boot-4 pattern) alongside new withTransaction tests
    - PagedResultSpec: add core.gorm.suite to @Requires
    - EnumSpec: restore findByEn()/findByEnInList() single-result tests
      without gates for core-test alongside new findAllBy versions
    
    Core-test specs:
    - Fix 6 specs disabled by @IgnoreIf(core.gorm.suite): update to
      addAllDomainClasses() for new GrailsDataTckManager API, restore
      missing imports, add targeted @Requires only where simple datastore
      genuinely cannot handle the query
    - OneToOneWithProxiesSpec: remove unnecessary @Requires gate
    
    All three suites verified green:
      core-test, hibernate5-core, mongodb-core
    
    Assisted-by: OpenCode <op...@opencode.ai>
---
 .../grails/gorm/tests/ReadOnlyCriteriaSpec.groovy  |   3 +-
 .../WhereMethodEmbeddedInAssociationSpec.groovy    |   8 +-
 .../datastore/gorm/CustomAutoTimestampSpec.groovy  |   5 +-
 .../gorm/EmbeddedPropertyQuerySpec.groovy          |   5 +-
 .../datastore/gorm/OneToOneWithProxiesSpec.groovy  |   1 -
 .../org/grails/datastore/gorm/OrderBySpec.groovy   |   7 +-
 .../datastore/gorm/QueryAssociationSpec.groovy     |   6 +-
 .../grails/data/testing/tck/tests/EnumSpec.groovy  |  68 ++++
 .../data/testing/tck/tests/FindByMethodSpec.groovy | 382 +++++++++++++++++++--
 .../testing/tck/tests/OptimisticLockingSpec.groovy |  64 +++-
 .../data/testing/tck/tests/PagedResultSpec.groovy  |   2 +-
 11 files changed, 489 insertions(+), 62 deletions(-)

diff --git a/grails-datamapping-core-test/src/test/groovy/grails/gorm/tests/ReadOnlyCriteriaSpec.groovy b/grails-datamapping-core-test/src/test/groovy/grails/gorm/tests/ReadOnlyCriteriaSpec.groovy
index a184a65e5c..8edb2673f8 100644
--- a/grails-datamapping-core-test/src/test/groovy/grails/gorm/tests/ReadOnlyCriteriaSpec.groovy
+++ b/grails-datamapping-core-test/src/test/groovy/grails/gorm/tests/ReadOnlyCriteriaSpec.groovy
@@ -20,10 +20,9 @@ package grails.gorm.tests
 
 import org.apache.grails.data.simple.core.GrailsDataCoreTckManager
 import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
+import org.apache.grails.data.testing.tck.domains.TestEntity
 import spock.lang.Issue
-import spock.lang.IgnoreIf
 
-@IgnoreIf({ System.getProperty('core.gorm.suite') == 'true' })
 class ReadOnlyCriteriaSpec extends GrailsDataTckSpec<GrailsDataCoreTckManager> {
 
     void setupSpec() {
diff --git a/grails-datamapping-core-test/src/test/groovy/grails/gorm/tests/WhereMethodEmbeddedInAssociationSpec.groovy b/grails-datamapping-core-test/src/test/groovy/grails/gorm/tests/WhereMethodEmbeddedInAssociationSpec.groovy
index 37cdab2d16..48287537aa 100644
--- a/grails-datamapping-core-test/src/test/groovy/grails/gorm/tests/WhereMethodEmbeddedInAssociationSpec.groovy
+++ b/grails-datamapping-core-test/src/test/groovy/grails/gorm/tests/WhereMethodEmbeddedInAssociationSpec.groovy
@@ -18,17 +18,13 @@
  */
 package grails.gorm.tests
 
-import spock.lang.Requires
-
 import org.apache.grails.data.simple.core.GrailsDataCoreTckManager
 import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
 import org.grails.datastore.gorm.query.transform.ApplyDetachedCriteriaTransform
 import org.grails.datastore.mapping.reflect.FieldEntityAccess
-import spock.lang.IgnoreIf
 import spock.lang.Shared
 
 @ApplyDetachedCriteriaTransform
-@IgnoreIf({ System.getProperty('core.gorm.suite') == 'true' })
 class WhereMethodEmbeddedInAssociationSpec extends GrailsDataTckSpec<GrailsDataCoreTckManager> {
     @Shared
     def gcl
@@ -73,9 +69,7 @@ class Partner {
         def Contact = this.gcl.loadClass("Contact")
         def Address = this.gcl.loadClass("Address")
 
-        manager.domainClasses << Partner
-        manager.domainClasses << Contact
-        manager.domainClasses << Address
+        manager.addAllDomainClasses([Partner, Contact, Address])
     }
 
     def setup() {
diff --git a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/CustomAutoTimestampSpec.groovy b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/CustomAutoTimestampSpec.groovy
index 78ccdfc7ac..f19d67493f 100644
--- a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/CustomAutoTimestampSpec.groovy
+++ b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/CustomAutoTimestampSpec.groovy
@@ -30,12 +30,9 @@ import org.grails.datastore.gorm.events.AutoTimestampEventListener
 
 import static grails.gorm.annotation.AutoTimestamp.EventType.CREATED
 
-import spock.lang.IgnoreIf
-
-@IgnoreIf({ System.getProperty('core.gorm.suite') == 'true' })
 class CustomAutoTimestampSpec extends GrailsDataTckSpec<GrailsDataCoreTckManager> {
     void setupSpec() {
-        manager.domainClasses.addAll([AutoTimestampedChildEntity, AutoTimestampedParentEntity, Image, RecordCustom, RecordWithAliases])
+        manager.addAllDomainClasses([AutoTimestampedChildEntity, AutoTimestampedParentEntity, Image, RecordCustom, RecordWithAliases])
     }
 
     @Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' ||
diff --git a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedPropertyQuerySpec.groovy b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedPropertyQuerySpec.groovy
index ab92684aed..9b0bf862e5 100755
--- a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedPropertyQuerySpec.groovy
+++ b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedPropertyQuerySpec.groovy
@@ -24,12 +24,9 @@ import grails.persistence.Entity
 import org.apache.grails.data.simple.core.GrailsDataCoreTckManager
 import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
 
-import spock.lang.IgnoreIf
-
-@IgnoreIf({ System.getProperty('core.gorm.suite') == 'true' })
 class EmbeddedPropertyQuerySpec extends GrailsDataTckSpec<GrailsDataCoreTckManager> {
     void setupSpec() {
-        manager.domainClasses += [Book2, Author2]
+        manager.addAllDomainClasses([Book2, Author2])
     }
 
     @Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' ||
diff --git a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/OneToOneWithProxiesSpec.groovy b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/OneToOneWithProxiesSpec.groovy
index 0870593cca..74343e045e 100644
--- a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/OneToOneWithProxiesSpec.groovy
+++ b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/OneToOneWithProxiesSpec.groovy
@@ -34,7 +34,6 @@ class OneToOneWithProxiesSpec extends GrailsDataTckSpec<GrailsDataCoreTckManager
         manager.addAllDomainClasses([ Face, Nose, Pet, org.apache.grails.data.testing.tck.domains.Person])
     }
 
-    @spock.lang.Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' || System.getProperty('hibernate7.gorm.suite') == 'true' || System.getProperty('mongodb.gorm.suite') == 'true' })
     void "Test persist and retrieve unidirectional many-to-one"() {
         given: "A domain model with a many-to-one"
         def person = new org.apache.grails.data.testing.tck.domains.Person(firstName: "Fred", lastName: "Flintstone")
diff --git a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/OrderBySpec.groovy b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/OrderBySpec.groovy
index 5adc6d6147..b9d1ecda3f 100644
--- a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/OrderBySpec.groovy
+++ b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/OrderBySpec.groovy
@@ -22,13 +22,11 @@ import org.apache.grails.data.testing.tck.domains.ChildEntity
 import org.apache.grails.data.testing.tck.domains.TestEntity
 import org.apache.grails.data.simple.core.GrailsDataCoreTckManager
 import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
+import spock.lang.Requires
 
 /**
  * @author Daniel Wiell
  */
-import spock.lang.IgnoreIf
-
-@IgnoreIf({ System.getProperty('core.gorm.suite') == 'true' })
 class OrderBySpec extends GrailsDataTckSpec<GrailsDataCoreTckManager> {
 
     def setupSpec() {
@@ -50,6 +48,9 @@ class OrderBySpec extends GrailsDataTckSpec<GrailsDataCoreTckManager> {
         45 == result.age
     }
 
+    @Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' ||
+            System.getProperty('hibernate7.gorm.suite') == 'true' ||
+            System.getProperty('mongodb.gorm.suite') == 'true' })
     def 'Test order by property name with dynamic finder using max'() {
         when:
         def results = TestEntity.findAllByAgeGreaterThanEquals(40, [sort: "age", order: 'desc', max: 1])
diff --git a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/QueryAssociationSpec.groovy b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/QueryAssociationSpec.groovy
index 0533d4972b..d5139a9d84 100644
--- a/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/QueryAssociationSpec.groovy
+++ b/grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/QueryAssociationSpec.groovy
@@ -19,18 +19,16 @@
 package org.grails.datastore.gorm
 
 import org.apache.grails.data.testing.tck.domains.ChildEntity
+import org.apache.grails.data.testing.tck.domains.Plant
 import org.apache.grails.data.testing.tck.domains.PlantCategory
 import org.apache.grails.data.testing.tck.domains.TestEntity
 import org.apache.grails.data.simple.core.GrailsDataCoreTckManager
 import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
 
-import spock.lang.IgnoreIf
-
-@IgnoreIf({ System.getProperty('core.gorm.suite') == 'true' })
 class QueryAssociationSpec extends GrailsDataTckSpec<GrailsDataCoreTckManager> {
 
     void setupSpec() {
-        manager.addAllDomainClasses([TestEntity,ChildEntity])
+        manager.addAllDomainClasses([TestEntity, ChildEntity, PlantCategory, Plant])
     }
 
     void "Test query one-to-one association with disjunction"() {
diff --git a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/EnumSpec.groovy b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/EnumSpec.groovy
index 7074de95bf..87b6a728e0 100644
--- a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/EnumSpec.groovy
+++ b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/EnumSpec.groovy
@@ -51,6 +51,74 @@ class EnumSpec extends GrailsDataTckSpec {
         TestEnum.V1 == t.en
     }
 
+    @Issue('GPMONGODB-248')
+    void "Test findByEnInList()"() {
+        given:
+
+        new EnumThing(name: 'e1', en: TestEnum.V1).save(failOnError: true)
+        new EnumThing(name: 'e2', en: TestEnum.V1).save(failOnError: true)
+        new EnumThing(name: 'e3', en: TestEnum.V2).save(failOnError: true)
+
+        when:
+        def instance1 = EnumThing.findByEn(TestEnum.V1)
+        def instance2 = EnumThing.findByEn(TestEnum.V2)
+        def instance3 = EnumThing.findByEn(TestEnum.V3)
+
+        then:
+        instance1 != null
+        instance1.en == TestEnum.V1
+
+        instance2 != null
+        instance2.en == TestEnum.V2
+
+        instance3 == null
+    }
+
+    void "Test findBy()"() {
+        given:
+
+        new EnumThing(name: 'e1', en: TestEnum.V1).save(failOnError: true)
+        new EnumThing(name: 'e2', en: TestEnum.V1).save(failOnError: true)
+        new EnumThing(name: 'e3', en: TestEnum.V2).save(failOnError: true)
+
+        when:
+        def instance1 = EnumThing.findByEn(TestEnum.V1)
+        def instance2 = EnumThing.findByEn(TestEnum.V2)
+        def instance3 = EnumThing.findByEn(TestEnum.V3)
+
+        then:
+        instance1 != null
+        instance1.en == TestEnum.V1
+
+        instance2 != null
+        instance2.en == TestEnum.V2
+
+        instance3 == null
+    }
+
+    void "Test findBy() with clearing the session"() {
+        given:
+
+        new EnumThing(name: 'e1', en: TestEnum.V1).save(failOnError: true, flush: true)
+        new EnumThing(name: 'e2', en: TestEnum.V1).save(failOnError: true, flush: true)
+        new EnumThing(name: 'e3', en: TestEnum.V2).save(failOnError: true, flush: true)
+        manager.session.clear()
+
+        when:
+        def instance1 = EnumThing.findByEn(TestEnum.V1)
+        def instance2 = EnumThing.findByEn(TestEnum.V2)
+        def instance3 = EnumThing.findByEn(TestEnum.V3)
+
+        then:
+        instance1 != null
+        instance1.en == TestEnum.V1
+
+        instance2 != null
+        instance2.en == TestEnum.V2
+
+        instance3 == null
+    }
+
     @Issue('GPMONGODB-248')
     @spock.lang.Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' || System.getProperty('hibernate7.gorm.suite') == 'true' || System.getProperty('mongodb.gorm.suite') == 'true' })
     void "Test findByInList()"() {
diff --git a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/FindByMethodSpec.groovy b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/FindByMethodSpec.groovy
index db85146bf5..9b909638d1 100644
--- a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/FindByMethodSpec.groovy
+++ b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/FindByMethodSpec.groovy
@@ -18,6 +18,7 @@
  */
 package org.apache.grails.data.testing.tck.tests
 
+import spock.lang.IgnoreIf
 import spock.lang.Requires
 
 import org.apache.grails.data.testing.tck.domains.Book as TckBook
@@ -28,76 +29,387 @@ import org.grails.datastore.mapping.core.exceptions.ConfigurationException
 import spock.lang.Unroll
 
 /**
- * Combined TCK Spec for Dynamic Finders.
- * Supports legacy Hibernate 5 behavior and validated Hibernate 7+ behavior.
+ * TCK Spec for Dynamic Finders.
+ *
+ * @author graemerocher
  */
 class FindByMethodSpec extends GrailsDataTckSpec {
 
     @Override
     void setupSpec() {
-        // Register domains in the TCK manager to prevent NoSuchElementException
         manager.addAllDomainClasses([Person, TckBook, Highway])
     }
 
-    // --- Standard GORM TCK Tests ---
-
-    @spock.lang.Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' || System.getProperty('hibernate7.gorm.suite') == 'true' || System.getProperty('mongodb.gorm.suite') == 'true' })
-    void "Test Using AND Multiple Times In A Dynamic Finder"() {
+    @Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' ||
+                System.getProperty('hibernate7.gorm.suite') == 'true' ||
+                System.getProperty('mongodb.gorm.suite') == 'true' })
+    void 'Test Using AND Multiple Times In A Dynamic Finder'() {
         given:
+        new Person(firstName: 'Jake', lastName: 'Brown', age: 11).save()
+        new Person(firstName: 'Zack', lastName: 'Brown', age: 14).save()
         new Person(firstName: 'Jeff', lastName: 'Brown', age: 41).save()
+        new Person(firstName: 'Zack', lastName: 'Galifianakis', age: 41).save()
+
+        when:
+        def people = Person.findAllByFirstNameAndLastNameAndAge('Jeff', 'Brown', 1)
+
+        then:
+        0 == people?.size()
+
+        when:
+        people = Person.findAllByFirstNameAndLastNameAndAgeGreaterThan('Zack', 'Brown', 20)
+
+        then:
+        0 == people?.size()
 
         when:
-        def people = Person.findAllByFirstNameAndLastNameAndAge('Jeff', 'Brown', 41)
+        people = Person.findAllByFirstNameAndLastNameAndAgeGreaterThan('Zack', 'Brown', 8)
 
         then:
         1 == people?.size()
+        14 == people[0].age
+
+        when:
+        def cnt = Person.countByFirstNameAndLastNameAndAge('Jake', 'Brown', 11)
+
+        then:
+        1 == cnt
+
+        when:
+        cnt = Person.countByFirstNameAndLastNameAndAgeInList('Zack', 'Brown', [12, 13, 14, 15])
+
+        then:
+        1 == cnt
+    }
+
+    @Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' ||
+                System.getProperty('hibernate7.gorm.suite') == 'true' ||
+                System.getProperty('mongodb.gorm.suite') == 'true' })
+    void 'Test Using OR Multiple Times In A Dynamic Finder'() {
+        given:
+        new Person(firstName: 'Jake', lastName: 'Brown', age: 11).save()
+        new Person(firstName: 'Zack', lastName: 'Brown', age: 14).save()
+        new Person(firstName: 'Jeff', lastName: 'Brown', age: 41).save()
+        new Person(firstName: 'Zack', lastName: 'Galifianakis', age: 41).save()
+
+        when:
+        def people = Person.findAllByFirstNameOrLastNameOrAge('Zack', 'Tyler', 125)
+
+        then:
+        2 == people?.size()
+
+        when:
+        people = Person.findAllByFirstNameOrLastNameOrAge('Zack', 'Brown', 125)
+
+        then:
+        4 == people?.size()
+
+        when:
+        def cnt = Person.countByFirstNameOrLastNameOrAgeInList('Jeff', 'Wilson', [11, 41])
+
+        then:
+        3 == cnt
     }
 
-    void "Test findOrCreateBy For A Record That Does Not Exist"() {
+    @Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' ||
+                System.getProperty('hibernate7.gorm.suite') == 'true' ||
+                System.getProperty('mongodb.gorm.suite') == 'true' })
+    void testBooleanPropertyQuery() {
+        given:
+        new Highway(bypassed: true, name: 'Bypassed Highway').save()
+        new Highway(bypassed: true, name: 'Bypassed Highway').save()
+        new Highway(bypassed: false, name: 'Not Bypassed Highway').save()
+        new Highway(bypassed: false, name: 'Not Bypassed Highway').save()
+
+        when:
+        def highways = Highway.findAllBypassedByName('Not Bypassed Highway')
+
+        then:
+        0 == highways.size()
+
+        when:
+        highways = Highway.findAllNotBypassedByName('Not Bypassed Highway')
+
+        then:
+        2 == highways?.size()
+        'Not Bypassed Highway' == highways[0].name
+        'Not Bypassed Highway' == highways[1].name
+
+        when:
+        highways = Highway.findAllBypassedByName('Bypassed Highway')
+
+        then:
+        2 == highways?.size()
+        'Bypassed Highway' == highways[0].name
+        'Bypassed Highway' == highways[1].name
+
+        when:
+        highways = Highway.findAllNotBypassedByName('Bypassed Highway')
+        then:
+        0 == highways?.size()
+
+        when:
+        highways = Highway.findAllBypassed()
+        then:
+        2 == highways?.size()
+        'Bypassed Highway' == highways[0].name
+        'Bypassed Highway' == highways[1].name
+
+        when:
+        highways = Highway.findAllNotBypassed()
+        then:
+        2 == highways?.size()
+        'Not Bypassed Highway' == highways[0].name
+        'Not Bypassed Highway' == highways[1].name
+
+        when:
+        def highway = Highway.findNotBypassed()
+        then:
+        'Not Bypassed Highway' == highway?.name
+
+        when:
+        highway = Highway.findBypassed()
+        then:
+        'Bypassed Highway' == highway?.name
+
+        when:
+        highway = Highway.findNotBypassedByName('Not Bypassed Highway')
+        then:
+        'Not Bypassed Highway' == highway?.name
+
+        when:
+        highway = Highway.findBypassedByName('Bypassed Highway')
+        then:
+        'Bypassed Highway' == highway?.name
+
+        when:
+        TckBook.newInstance(author: 'Jeff', title: 'Fly Fishing For Everyone', published: false).save()
+        TckBook.newInstance(author: 'Jeff', title: 'DGGv2', published: true).save()
+        TckBook.newInstance(author: 'Graeme', title: 'DGGv2', published: true).save()
+        TckBook.newInstance(author: 'Dierk', title: 'GINA', published: true).save()
+
+        def book = TckBook.findPublishedByAuthor('Jeff')
+        then:
+        'Jeff' == book.author
+        'DGGv2' == book.title
+
+        when:
+        book = TckBook.findPublishedByAuthor('Graeme')
+        then:
+        'Graeme' == book.author
+        'DGGv2' == book.title
+
+        when:
+        book = TckBook.findPublishedByTitleAndAuthor('DGGv2', 'Jeff')
+        then:
+        'Jeff' == book.author
+        'DGGv2' == book.title
+
+        when:
+        book = TckBook.findNotPublishedByAuthor('Jeff')
+        then:
+        'Fly Fishing For Everyone' == book.title
+
+        when:
+        book = TckBook.findPublishedByTitleOrAuthor('Fly Fishing For Everyone', 'Dierk')
+        then:
+        'GINA' == book.title
+        TckBook.findPublished() != null
+
+        when:
+        book = TckBook.findNotPublished()
+        then:
+        'Fly Fishing For Everyone' == book?.title
+
+        when:
+        def books = TckBook.findAllPublishedByTitle('DGGv2')
+        then:
+        2 == books?.size()
+
+        when:
+        books = TckBook.findAllPublished()
+        then:
+        3 == books?.size()
+
+        when:
+        books = TckBook.findAllNotPublished()
+        then:
+        1 == books?.size()
+
+        when:
+        books = TckBook.findAllPublishedByTitleAndAuthor('DGGv2', 'Graeme')
+        then:
+        1 == books?.size()
+
+        when:
+        books = TckBook.findAllPublishedByAuthorOrTitle('Graeme', 'GINA')
+        then:
+        2 == books?.size()
+
+        when:
+        books = TckBook.findAllNotPublishedByAuthor('Jeff')
+        then:
+        1 == books?.size()
+
+        when:
+        books = TckBook.findAllNotPublishedByAuthor('Graeme')
+        then:
+        0 == books?.size()
+    }
+
+    void "Test findOrCreateBy For A Record That Does Not Exist In The Database"() {
         when:
         def book = TckBook.findOrCreateByAuthor('Someone')
 
         then:
         'Someone' == book.author
+        null == book.title
         null == book.id
     }
 
-    // --- Parameterized Logic ---
+    void "Test findOrCreateBy With An AND Clause"() {
+        when:
+        def book = TckBook.findOrCreateByAuthorAndTitle('Someone', 'Something')
 
-    @Unroll
-    @Requires({ System.getProperty('hibernate5.gorm.suite') == 'true'  })
-    void "Test Hib5 pattern [#index] #methodName should throw MissingMethodException"() {
+        then:
+        'Someone' == book.author
+        'Something' == book.title
+        null == book.id
+    }
+
+    void "Test findOrCreateBy Throws Exception If An OR Clause Is Used"() {
         when:
-        action.call()
+        TckBook.findOrCreateByAuthorOrTitle('Someone', 'Something')
 
         then:
         thrown(MissingMethodException)
+    }
 
-        where:
-        index | methodName                                | action
-        // findOrCreateBy patterns
-        1     | 'findOrCreateByAuthorOrTitle'             | { TckBook.findOrCreateByAuthorOrTitle('Jim', 'Title') }
-        2     | 'findOrCreateByAuthorGreaterThan'         | { TckBook.findOrCreateByAuthorGreaterThan('B') }
-        3     | 'findOrCreateByAuthorLessThan'            | { TckBook.findOrCreateByAuthorLessThan('B') }
-        4     | 'findOrCreateByAuthorGreaterThanEquals'   | { TckBook.findOrCreateByAuthorGreaterThanEquals('B') }
-        5     | 'findOrCreateByAuthorLessThanEquals'      | { TckBook.findOrCreateByAuthorLessThanEquals('B') }
-        6     | 'findOrCreateByAuthorInList'              | { TckBook.findOrCreateByAuthorInList(['Jeff']) }
-        7     | 'findOrCreateByAuthorNotEqual'            | { TckBook.findOrCreateByAuthorNotEqual('B') }
-        8     | 'findOrCreateByAuthorBetween'             | { TckBook.findOrCreateByAuthorBetween('A', 'B') }
+    void "Test findOrSaveBy For A Record That Does Not Exist In The Database"() {
+        when:
+        def book = TckBook.findOrSaveByAuthorAndTitle('Some New Author', 'Some New Title')
 
-        // findOrSaveBy patterns
-        9     | 'findOrSaveByAuthorInList'                | { TckBook.findOrSaveByAuthorInList(['Jeff']) }
-        10    | 'findOrSaveByAuthorOrTitle'               | { TckBook.findOrSaveByAuthorOrTitle('Jim', 'Title') }
-        11    | 'findOrSaveByAuthorNotEqual'              | { TckBook.findOrSaveByAuthorNotEqual('B') }
-        12    | 'findOrSaveByAuthorGreaterThan'           | { TckBook.findOrSaveByAuthorGreaterThan('B') }
-        13    | 'findOrSaveByAuthorLessThan'              | { TckBook.findOrSaveByAuthorLessThan('B') }
-        14    | 'findOrSaveByAuthorBetween'               | { TckBook.findOrSaveByAuthorBetween('A', 'B') }
-        15    | 'findOrSaveByAuthorGreaterThanEquals'     | { TckBook.findOrSaveByAuthorGreaterThanEquals('B') }
-        16    | 'findOrSaveByAuthorLessThanEquals'        | { TckBook.findOrSaveByAuthorLessThanEquals('B') }
+        then:
+        'Some New Author' == book.author
+        'Some New Title' == book.title
+        book.id != null
+    }
+
+    void "Test findOrSaveBy For A Record That Does Exist In The Database"() {
+
+        given:
+        def originalId = new TckBook(author: 'Some Author', title: 'Some Title').save().id
+
+        when:
+        def book = TckBook.findOrSaveByAuthor('Some Author')
+
+        then:
+        'Some Author' == book.author
+        'Some Title' == book.title
+        originalId == book.id
+    }
+
+    @IgnoreIf({ System.getProperty('hibernate7.gorm.suite') == 'true' })
+    void "Test patterns which shold throw MissingMethodException"() {
+        when:
+        TckBook.findOrCreateByAuthorInList(['Jeff'])
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrCreateByAuthorOrTitle('Jim', 'Title')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrCreateByAuthorNotEqual('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrCreateByAuthorGreaterThan('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrCreateByAuthorLessThan('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrCreateByAuthorBetween('A', 'B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrCreateByAuthorGreaterThanEquals('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrCreateByAuthorLessThanEquals('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrSaveByAuthorInList(['Jeff'])
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrSaveByAuthorOrTitle('Jim', 'Title')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrSaveByAuthorNotEqual('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrSaveByAuthorGreaterThan('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrSaveByAuthorLessThan('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrSaveByAuthorBetween('A', 'B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrSaveByAuthorGreaterThanEquals('B')
+
+        then:
+        thrown(MissingMethodException)
+
+        when:
+        TckBook.findOrSaveByAuthorLessThanEquals('B')
+
+        then:
+        thrown(MissingMethodException)
     }
 
     @Unroll
-    @Requires({ System.getProperty('hibernate7.gorm.suite') == 'true'  })
+    @Requires({ System.getProperty('hibernate7.gorm.suite') == 'true' })
     void "Test Hib7 pattern [#index] #methodName should throw #exception.simpleName"() {
         when:
         action.call()
diff --git a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/OptimisticLockingSpec.groovy b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/OptimisticLockingSpec.groovy
index 239e266c0b..fb64b1deb1 100644
--- a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/OptimisticLockingSpec.groovy
+++ b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/OptimisticLockingSpec.groovy
@@ -18,6 +18,7 @@
  */
 package org.apache.grails.data.testing.tck.tests
 
+import spock.lang.IgnoreIf
 import spock.lang.Requires
 
 import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
@@ -25,10 +26,13 @@ import org.apache.grails.data.testing.tck.domains.OptLockNotVersioned
 import org.apache.grails.data.testing.tck.domains.OptLockVersioned
 import org.springframework.dao.OptimisticLockingFailureException
 
+import grails.gorm.transactions.GrailsTransactionTemplate
+import org.grails.datastore.mapping.core.OptimisticLockingException
+
 /**
  * @author Burt Beckwith
  */
-@Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' || System.getProperty('hibernate7.gorm.suite') == 'true' })
+@Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' || System.getProperty('hibernate7.gorm.suite') == 'true' || System.getProperty('mongodb.gorm.suite') == 'true' })
 class OptimisticLockingSpec extends GrailsDataTckSpec {
 
     def setupSpec() {
@@ -63,6 +67,7 @@ class OptimisticLockingSpec extends GrailsDataTckSpec {
         o.version == 1
     }
 
+    @IgnoreIf({ System.getProperty('mongodb.gorm.suite') == 'true' })
     void "Test optimistic locking"() {
 
         given:
@@ -105,6 +110,7 @@ class OptimisticLockingSpec extends GrailsDataTckSpec {
         thrown OptimisticLockingFailureException
     }
 
+    @IgnoreIf({ System.getProperty('mongodb.gorm.suite') == 'true' })
     void "Test optimistic locking disabled with 'version false'"() {
         given:
         def o = new OptLockNotVersioned(name: 'locked').save(flush: true)
@@ -145,4 +151,60 @@ class OptimisticLockingSpec extends GrailsDataTckSpec {
         ex == null
         o.name == 'locked in main session'
     }
+
+    @IgnoreIf({ System.getProperty('hibernate5.gorm.suite') == 'true' || System.getProperty('hibernate7.gorm.suite') == 'true' })
+    void "Test optimistic locking with withNewSession"() {
+
+        given:
+        def o = new OptLockVersioned(name: 'locked').save(flush: true)
+        manager.session.clear()
+
+        when:
+        o = OptLockVersioned.get(o.id)
+
+        OptLockVersioned.withNewSession { session ->
+            def reloaded = OptLockVersioned.get(o.id)
+            reloaded.name += ' in new session'
+            reloaded.save(flush: true)
+        }
+
+        o.name += ' in main session'
+        o.save(flush: true)
+
+        then:
+        thrown OptimisticLockingException
+    }
+
+    @IgnoreIf({ System.getProperty('hibernate5.gorm.suite') == 'true' || System.getProperty('hibernate7.gorm.suite') == 'true' })
+    void "Test optimistic locking disabled with 'version false' using withNewSession"() {
+        given:
+        def o = new OptLockNotVersioned(name: 'locked').save(flush: true)
+        manager.session.clear()
+
+        when:
+        o = OptLockNotVersioned.get(o.id)
+
+        OptLockNotVersioned.withNewSession { session ->
+            def reloaded = OptLockNotVersioned.get(o.id)
+            reloaded.name += ' in new session'
+            reloaded.save(flush: true)
+        }
+
+        def ex
+        try {
+            o.name += ' in main session'
+            o.save(flush: true)
+        }
+        catch (e) {
+            ex = e
+            e.printStackTrace()
+        }
+
+        manager.session.clear()
+        o = OptLockNotVersioned.get(o.id)
+
+        then:
+        ex == null
+        o.name == 'locked in main session'
+    }
 }
diff --git a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/PagedResultSpec.groovy b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/PagedResultSpec.groovy
index c4cd1c3397..781a4bfefa 100644
--- a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/PagedResultSpec.groovy
+++ b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/PagedResultSpec.groovy
@@ -21,7 +21,7 @@ package org.apache.grails.data.testing.tck.tests
 import org.apache.grails.data.testing.tck.domains.Person
 import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
 
-@spock.lang.Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' ||  System.getProperty('mongodb.gorm.suite') == 'true' })
+@spock.lang.Requires({ System.getProperty('hibernate5.gorm.suite') == 'true' || System.getProperty('mongodb.gorm.suite') == 'true' || System.getProperty('core.gorm.suite') == 'true' })
 class PagedResultSpec extends GrailsDataTckSpec {
 
     void setupSpec() {