Rolling back a transaction in a Grails Service
- by UltraVi01
I have been updating all my services to be transactional by using Grail's ability to rollback when a RuntimeException is thrown in the service. I have, in most cases, doing this:
def domain = new Domain(field: field)
if (!domain.save()) {
throw new RuntimeException()
}
Anyways, I wanted to verify that this indeed will rollback the transaction... it got me thinking as to whether at this point it's already been committed.. Also, if not, would setting flush:true change that? I am not very familiar with how Spring/Hibernate does all of this :)