Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

BadriNath Ojha
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am saving one entity in the database using the 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, 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic