0 votes
in Hibernate by
What is the difference between save and saveorupdate in hibernate ?

1 Answer

0 votes

There are following difference between save and saveorupdate:

1) The save() method generates a new identifier and INSERT record into database.
2) This method saves records into database by generating INSERT SQL query.
3) It generates a new identifier and return the Serializable identifier back.
4) It returns a Serializable object.
5) The save() method in Hibernate is that is there behavior on outside of transaction boundaries.

1) The saveOrUpdate() method can either INSERT or UPDATE records based upon existence.
2) The saveOrUpdate is more flexible to use but it involves an extra processing to find whether record is already exists in table or not.
3) The saveOrUpdate() method either INSERT or UPDATE records based upon existence of object in database. If persistence object is already exists in database then UPDATE SQL will execute and if do not found object in database than INSERT will run.

Share:- Whatsapp Facebook Facebook

Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.