I recently ran into, what I thought to be, a bug with the isDirty domain class method. It turns out, the isDirty() method only looks at regular domain fields, not collections. It would be nice if the Grails User Guide covered this. I have attached Burt Beckwith's explanation of isDirty() from the mailing list for reference.
From the grails user mailing list:
[grails-user] Odd persistence behavior
from Burt Beckwith <email@example.com>
The isDirty() check only looks at regular fields, not collections. But the 'things' list is a Hibernate PersistentList so you can check if it's been modified by calling aInstance.things.isDirty()
The Hibernate session acts as the 1st-level cache, so calling get() repeatedly always returns the instance that's cached in the session from the first load.
You can bypass the cache by using A.findById(the_id_in_question) but that will trigger another behavior that will defeat things - it will force a flush. Hibernate waits to push to the database as long as possible and does so when explicitly flushed, but also at the end of a transaction, and in this case before a query since it doesn't know if the result could be affected by unflushed data.