adspace


What is the difference between save() and persist() methods of session object?

Answer Posted / Girja Shankar Vishwakarma

Both save() and persist() methods in Hibernate are used to store Java objects (entities) into the database, but they have subtle differences:
1. Persist(): This method does not automatically flush or synchronize the state of the entity with the database. Instead, it marks the entity as persistent, meaning that its state will be saved when a transaction is flushed or committed.
2. Save(): This method both marks the entity as persistent and flushes the session immediately. So, if you use save(), the entity gets saved directly into the database.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is latest hibernate version?

493