In this post, We will try to understand the difference between save vs persist in Hibernate.
save(obj) | persist(ob) |
It returns generated id and the return type is serializable | It does not return anything. It’s a void return type. |
It can save object within boundaries and outside boundaries | It can only save object within the transaction boundaries |
It is only supported by Hibernate | It is also supported by JPA |
Save() operation cascades the associated instances if the association is mapped with cascade=”save-update” | Persist() operation cascades the associated instances if the association is mapped with cascade=”persist”. |
You May Also Like:
Create SessionFactory in Hibernate5 without hibernate.cfg.xml
Save and persist an entity example in hibernate
Hibernate CRUD(Create,Read,Update and Delete) example
Dirty checking in hibernate example
Understanding hibernate Configuration File
Why to use hibernate dialect?
Hibernate hbm2ddl property
What are the benefits of using hibernate?
Save and persist an entity example in hibernate
Hibernate CRUD(Create,Read,Update and Delete) example
Dirty checking in hibernate example
Understanding hibernate Configuration File
Why to use hibernate dialect?
Hibernate hbm2ddl property
What are the benefits of using hibernate?
That’s all about the difference between save vs persist in Hibernate