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
@transactionalwhen 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
@transactionalannotation 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
Post a Comment