Search code examples
grailsdnssavegrails-orm

Grails save() method bug


For example I have entity person saved in db with the name John and id 1 then:

def person = Person.get(1) 
person.name = 'Maria'
person.save()

//after that name still will be John
//but if I save one more time than name be Maria

Addition information is that my domain have inside service, and method that work with this service. I don't now in what is a problem, maybe somebody had already this situation.


Solution

  • It's not flushed at this moment, changes kept in memory for a while. If you need to force Grails to update DB exactly at this moment, add flush: true parameter:

    person.save(flush: true)