• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why to use session.beginTransaction & transaction.commit

 
Krishnaa Kumar
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate:
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.
-Krishna
 
Anurag Verma
Ranch Hand
Posts: 165
Hibernate Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic