java - Should I avoid using the annotation @Transactional when the transaction only reads data? -


i've migrated old style of transaction management transactionproxyfactorybean declarative transaction management recommended spring avoid exceptions transactions appear time time.

for transactions save update delete added annotation:

@transactional(propagation = propagation.required, rollbackfor = exception.class)

it works me.

the question is:

should avoid using annotation @transactional when transaction reads data?

example:

public tradedata gettrade(long tradeid) throws exception {    return em.find(tradedata.class, tradeid); } 

after reading this article, says:

"better yet, avoid using @transactional annotation altogether when doing read operations, shown in listing 10:"

i'm little confused , don't quite understand it.

for read-only operations jdbc don't need @transactional because doesn't need transaction, hibernate does! can use @transactional(readonly = true). sure don't update, delete, insert accident.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -