why to use session.beginTransaction & transaction.commit
posted 5 years ago
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.
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.
Yes it can be done, we just have to figure out how.