I met a situation when I am unable to save certain objects persistently. The objects look like successfully saved ones but later I cannot find them in DB. There is no errors or notifications appearing in console (usually they do on errors). What that could be?
// inside a transactioned service method
def m1 = new Merchant(...)
assert m1.save() // ok
assert m1.id // got some good id
assert Merchant.findById(m1.id) // it fails o_O
Other objects are saved normally.
Grails 2.1.1, some Oracle
Hibernate will typically only flush objects to the database at the end of a session. Flush the session manually with
sessionFactory.currentSession.flush()or save the object withm1.save(flush: true)to force the object to be written out before the session is done.