我需要在grails服务中手动执行事务回滚。
有没有没有抛出RuntimeException的方法? (使用Grails 2.4.5)
最佳答案
是的,通过使用.withTransaction {}
块。喜欢:
MyDomain.withTransaction { status ->
....
status.setRollbackOnly() //when you want rollback
}
MyDomain
可以是任何域类,而不是此事务中使用的必需域。参见http://grails.github.io/grails-doc/latest/guide/GORM.html#programmaticTransactions
关于grails - 在grails服务中手动回滚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31539780/