aspose file tools*
The moose likes Spring and the fly likes what is read only transaction and how it helps me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "what is read only transaction and how it helps me" Watch "what is read only transaction and how it helps me" New topic
Author

what is read only transaction and how it helps me

srini carry
Ranch Hand

Joined: Nov 30, 2007
Posts: 83
read-only transation , why should I use this , how this transaction attribute can help me ? please explain me advantages of using read-only attribute for a transaction, I donto know If I should I use this or not
Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
As Spring documentation states:
Read-only status: a read-only transaction does not modify any data. Read-only transactions can be a useful optimization in some cases (such as when using Hibernate).
srini carry
Ranch Hand

Joined: Nov 30, 2007
Posts: 83
Eduardo Bueno wrote:As Spring documentation states:
Read-only status: a read-only transaction does not modify any data. Read-only transactions can be a useful optimization in some cases (such as when using Hibernate).


why is it useful with hibernate , how can I decide whether to use it or not ?
Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
Use it in transactions where you are simply fetching data, i.e. SELECT statements. I don't know what the documentation means when referring to Hibernate.
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
Yes as previous posters suggest, use when fetching data. If using hibernate, by using this you can avoid having to lazy load things since it keeps the session open until the need of the transaction. The alternative is to set lazy="false" in hibernate which can lead to lots of worse things such as loading huge object graphs when not needed.
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225

open until the need of the transaction


should be "open until the end of the transaction"
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: what is read only transaction and how it helps me