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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -