0
我需要在grails服务中手动执行事务回滚。 有什么办法没有抛出一个RuntimeException? (使用Grails 2.4.5)在grails服务中手动回滚
我需要在grails服务中手动执行事务回滚。 有什么办法没有抛出一个RuntimeException? (使用Grails 2.4.5)在grails服务中手动回滚
是的,通过使用.withTransaction {}
块。像:
MyDomain.withTransaction { status ->
....
status.setRollbackOnly() //when you want rollback
}
MyDomain
可以在此交易中使用的任何域类,没有必要的域。
请参阅http://grails.github.io/grails-doc/latest/guide/GORM.html#programmaticTransactions