borinquenkid commented on code in PR #15568:
URL: https://github.com/apache/grails-core/pull/15568#discussion_r3454246900


##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/CompositeIdWithJoinTableSpec.groovy:
##########
@@ -19,45 +19,40 @@
 
 package grails.gorm.tests
 
-import static grails.gorm.hibernate.mapping.MappingBuilder.define
-
 import grails.gorm.annotation.Entity
-import grails.gorm.transactions.Rollback
-import org.grails.orm.hibernate.HibernateDatastore
-import org.springframework.transaction.PlatformTransactionManager
-import spock.lang.AutoCleanup
-import spock.lang.Shared
-import spock.lang.Specification
+
+import static grails.gorm.hibernate.mapping.MappingBuilder.define
 
 /**
  * Created by graemerocher on 26/01/2017.
  */
-class CompositeIdWithJoinTableSpec extends Specification {
-
-    @AutoCleanup @Shared HibernateDatastore datastore = new 
HibernateDatastore(CompositeIdParent, CompositeIdChild)
-    @Shared PlatformTransactionManager transactionManager = 
datastore.transactionManager
+class CompositeIdWithJoinTableSpec extends HibernateGormDatastoreSpec {
+    def setupSpec() {
+        manager.registerDomainClasses(CompositeIdParent, CompositeIdChild)
+    }
 
-    @Rollback
+    //    @Rollback
     void "test composite id with join table"() {
-        when:"A parent with a composite id and a join table is saved"
-        new CompositeIdParent(name: "Test" , last:"Test 2")
-                .addToChildren(new CompositeIdChild())
-                .save(flush:true)
+        when: "A parent with a composite id and a join table is saved"
+        new CompositeIdParent(name: "Test", last: "Test 2")
+                .addToChildren(new CompositeIdChild(foo: "bar"))
+                .save(flush: true)
 
 
-        then:"The entity was saved"
+        then: "The entity was saved"
         CompositeIdParent.count() == 1
         CompositeIdParent.list().first().children.size() == 1
     }
 }
 
 @Entity
-class CompositeIdParent implements Serializable {
+class CompositeIdParent implements Serializable, Comparable<CompositeIdParent> 
{

Review Comment:
   The `SortedSet` and `Comparable` on both classes are intentional 
improvements: composite ID entities should implement `Comparable` as a best 
practice, and `SortedSet` gives deterministic ordering vs the non-deterministic 
`HashSet` default. `CompositeIdChild` also got `String foo`, `belongsTo`, and a 
real test value. The H7 spec was behind — it still used the old 
`Specification`/`@Rollback`/`@AutoCleanup` pattern without any of these. 
Applied all improvements to H7 as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to