This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Want to know internals of session's save() method in Hibernate ORM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Want to know internals of session Watch "Want to know internals of session New topic
Author

Want to know internals of session's save() method in Hibernate ORM

BadriNath Ojha
Greenhorn

Joined: Aug 05, 2012
Posts: 10

I am saving one entity in the database using the session.save(Object obj) method. I have set the auto commit as true in the config file. The ID generator is "native".
The entity is saved properly.
Wanted to understand the save() behavior when the ID generator is changed to assigned. In case it is assigned it does not inserts the entity.
Please explain with reference to persistence context of session object, and database.
Also, why do we need flush(), if save() saves data in the DB and I could see that after flush the size of persistence context object does not changes, then what is the reason for it.
Another point, reading http://docs.jboss.org/hibernate/orm/3.5/reference/en/html/transactions.html, It mentions that data base transactions are never optional. But in case the ID generator is native and after I flush the session, the changes are reflected in the DB. I am using mySql as DB. Is it that save internally opens a DB transaction of mySql in case ID is native.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Want to know internals of session's save() method in Hibernate ORM
 
Similar Threads
EJB3 Beta Certification - EntityManager BASIC notes.
EJB3 Beta Certification - Help =))
Seam and persistence context management
Query about save(), saveorupdate(), update(), lock() and merge() methods
Passed SCBCD 5.0 :)