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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -