grails - Annotate Controller method to make Hibernate session "read-only" -
i've got app method that, reason can't figure out, saving object load @ end of controller method, though specify shouldn't.
def testmethod( long id ) { def target = sampledomain.read( id ); // use target in further query, don't change target @ // i've checked, , target.isdirty() false here target.discard() render( view: 'blah', model: [ /* model not contain target */ ] ) }
for reason, if turn on logsql, can see target object being saved @ end of method, though use "read" , "discard". version field seems db field being changed in table.
is there way annotate method make sure no "updates" performed during controller method's session? admit not being knowledgeable possible arguments @transactional annotation.
i'm using grails v2.2.4.
it seem easier imagined. need readonly argument transactional annotation:
@transactional(readonly = true) def testmethod( long id ) { def target = sampledomain.read( id ); // use target in further query, don't change target @ // i've checked, , target.isdirty() false here render( view: 'blah', model: [ /* model not contain target */ ] ) }
i'm still not sure why updating object after used discard() method... don't need it.
Comments
Post a Comment