aspose file tools*
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
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