Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Without marking transaction demarcation, just loading an entity through session

 
Krishnaa Kumar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if I load an entity saying session.load() and close the session without beginning a transaction & comitting it
I gone through various sites, but couldn't find any good explanation.

 
Anurag Verma
Ranch Hand
Posts: 168
Hibernate Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i understood your question correctly, you want to know the effect of reading an entity without having any transaction. If so, then there is no adverse effect. Transactions are supposed to be used where you are making any kind of change in the database (like insert/update/delete operations). Just to read an Entity, transaction should not be used.
 
Krishnaa Kumar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply.

In the following post it says, if we access an entity in non-transactional way, we need to enable auto-commit in hibernate configuration.
If not, once we close the session (we used for retrieving the entity) the database connection returning to the pool will have some issues/memory leaks.

https://community.jboss.org/wiki/OpenSessionInView

lines in this link "the connection is in whatever mode it is by default after obtained from the pool, and returned there without commit or rollback. The behavior is then undefined."

kindly make me clear here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic