1

I am using hibernate-PostgreSQL in my application and I am using application-managed entity manager to perform database operations.

I have a very basic question regarding whether it is required/recommended to start a transaction for reading records from database? If yes, won’t it make extra work to manage the transaction? We need to make sure rollback is done after reading, if not it will cause connection leak. Make sure transaction is not kept open for long as it can cause unnecessary resource usage and so on.

Hibernate document says "Always use clear transaction boundaries, even for read-only operations.". What would be the advantage of starting transaction if I just want to read some records from database? Is it only for batching multiple read operations using single transaction?

Niki
  • 11
  • 2
  • Does this answer your question? [Why do I need Transaction in Hibernate for read-only operations?](https://stackoverflow.com/questions/13539213/why-do-i-need-transaction-in-hibernate-for-read-only-operations) – Simon Martinelli Apr 18 '20 at 08:30

0 Answers0