This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.