yvesf opened a new issue, #14627: URL: https://github.com/apache/grails-core/issues/14627
Please see the following test for grails-datastore-gorm-test: [gist SaveCascadeSpec.groovy](https://gist.github.com/yvesf/8560eacf42e40ba0cced95b5951d9888) It contains two cases for two relation types: - `ToOne`: This one fails in gorm 4.x branch and 5.x branch. It looks like a incomplete logic in NativeEntryEntityPersister - `OneToMany`: This one succeeds in gorm 4.x, it fails in 5.x branch. As it is shown in the test, I assume that a entity with a association where the other end `belongsTo` should cascade on save. This is what I understood from the 'cascade' help in the docs. My idea to fix the `ToOne` is to not only check for empty id but also do the dirty check in the NativeEntryEntityPersister: ```groovy // else if (prop instanceof ToOne) { ... if (tempId == null) { if (association.isOwningSide()) { tempId = session.persist(associatedObject); } } else if (associatedObject instanceof DirtyCheckable) { if (((DirtyCheckable)associatedObject).hasChanged()) { tempId = associationPersister.persist(associatedObject); } } ``` For the `OneToMany` I have currently no idea how to fix it. I just realized that in the NativeEntityPersister is only checking if the PersistentSet is dirty. This is not the case, it's the entry inside the PersistentSet that is dirty. -- 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]
