mongodb - grails mongo transaction rollback with save(flush:true)? -


i have issueinstance , has many issueiteminstances,

and 1 issueiteminstance has 1 receiptiteminstance(many-to-one),

when issueinstance.save(flush:true, failonerror:true),

i'd recalculate receiptiteminstance.quantity looping issueiteminstances other saved issueiteminstance.quantity(many-to-one),

and when !receiptiteminstance.validate()(e.g. quantity big),

i'd rollback,

but seems doesn't work 1.static transactional = 'mongo' , 2. issue.withtransaction

when throw exception,the issueinstance , issueiteminstances not deleted.

if save(), it'd not recalculate correct because issueiteminstance not saved yet.

is there hint or way manual?

i use mongodb gorm ':mongodb:3.0.1'

thank much,

mark

use:

issue.withtransaction { status ->     issue issueinstance // issue instance     def receiptiteminstance // receipt item instance      if (!receiptiteminstance.validate()) {         status.setrollbackonly()         return   // exit transaction block     }     // conitune code } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -