Grails provides an isDirty method that can be called on domain objects. How would one modify the Grails domain model system, such that one could simply call a method, to find out if any domain objects are dirty.
I’m struggling with some “unsaved transient instance” errors that I haven’t been able to nail down, and it’d be great to know what’s dirty. Is there an elegant way to do this with groovy?
Add this to BootStrap.groovy:
This adds an
isDirty()method to Hibernate sessions that checks that top-level instances or instances in collections are dirty and you can use it withwithSession, e.g.or if you have access to the
sessionFactorybean (e.g. from adef sessionFactorydependency injection)