Grails MongoDB doesn't save in afterUpdate -
i'm trying put of domain classes mongodb using mongodb grails plugin. of classes stays in mysql. works fine saving of domain class instances mongodb (for example in service on controller code). however, if try save instance afterupdate() of not-mongodb class doesn't work. doesn't throw exception or whatever...
my not-mongodb domain class:
class carstate extends abstractcarstate { ... def afterupdate() { def logiteminstance = new carstatelogitem(this.properties) logiteminstance.save(failonerror: true) } }
mongodb domain class:
class carstatelogitem extends abstractcarstate { objectid id static mapwith = "mongo" ... }
the weird thing if run afterupdate() code controller saves mongodb. missing? or why cannot save instance?
thanks advice, mateo
i think need initiate new transaction
in order save in mongodb. if notice, transaction carstate
of mysql
. in order transact mongodb
afterupdate
event there has new mongodb transaction. try this.
def afterupdate() { carstatelogitem.withtransaction{status -> def logiteminstance = new carstatelogitem(this.properties) logiteminstance.save(failonerror: true) } }
Comments
Post a Comment