permaculture playing cards
The moose likes Object Relational Mapping and the fly likes why to use session.beginTransaction & transaction.commit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "why to use session.beginTransaction & transaction.commit" Watch "why to use session.beginTransaction & transaction.commit" New topic

why to use session.beginTransaction & transaction.commit

Krishnaa Kumar

Joined: May 05, 2011
Posts: 25
If any Transient object was added into hibernate session, why can't hibernate persist it(after its dirty checking) when i close the session. Is there any such of kind of option available.
Also, if such option exists, then why we are beginning a transaction & saying it to commit. (session.beginTransaction() )

what functionality that transaction.commit() does can also be done once we say session.close() right?
Kindly any one explain me about this.

thanks in advance.
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 128

If you don't want to write code to begin & end transaction, you can use Spring & have annotation based transactions . but in that case Spring will handle starting & ending the transactions. i know i didn't answer your "why" part, i apologize for that.
I agree. Here's the link:
subject: why to use session.beginTransaction & transaction.commit
It's not a secret anymore!