What is the difference between save() and persist() methods of session object?
Answer / 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 |
What is orm navy?
Does hibernate work without primary key?
Is it possible to perform collection mapping with one-to-one and many-to-one?
What is hql in hadoop?
Why we use hibernate template?
Explain some of the elements of hbm.xml?
How to insert data into database using spring mvc and hibernate?
How many tables are required for many to many relationship?
Which settings will be loaded if both hibernate.properties and hibernat.cf.xml files are present in the classpath?
What is the purpose of orm?
Define the collection types in hibernate?
What is l1 and l2 cache in hibernate?