• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate Queries and Transactions

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've set up some Hibernate transactions and queries to select data from the database, update it, and then save the results back to the database.

However, now I just want to get a list of some of the items in the database. I don't need to make any changes at all. So I don't need to commit or rollback. However, will just running the query leave the transaction open if I don't call commit or rollback?

What's the proper way to query the database if you don't intend to change anything? I couldn't seem to find anything concerning this in the searches I did.

TIA.
 
Ranch Hand
Posts: 84
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Bai, i don't know if it leaves the transaction open or not, i think that it depends.

It depends on the transaction manager that you are using if any, and if the there it's a
transaction timeout associated with it.

I prefer to always starts and commit a transaction to denote a unit of work. It's a nice
recommendation, 'cause, some of the objects associated with the session can be eligible for GC (if no caching is used).

regards,
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic