Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transaction when we "select" data from db ?

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Do we need a transaction when we "select" data from db ? The coding is below, though it is hibernate version.

Thanks.

 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what you want to do with the data. If you plan on updating the data but there was no transaction, then there would be no guarantee on the data at the point you go to save your records.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may strongly depend on the database. In Oracle, for example, you can start the transaction in serializable mode (or read-only mode for that matter, though JDBC does not directly support read-only transactions) and all your selects will return data as they existed at the time the transaction started. This may be important in regard to the consistency of data being read.

In other databases the transaction (and its isolation level) might affect the results in different ways.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic