Saveorupdate () If the incoming object has an update operation in the database, do the save operation if it is not.
Save () generates a record in the database and, if there is one in the database, an error message that there is a duplicate record.
Update () is updating records in the database
The primary key plays a key role in the Saveorupdate () method, only if the value of the primary key is not empty, insert or update is determined, otherwise the direct insert
If the primary key is not empty, the saveorupdate () operation can be performed.
Saveorupdate is when you use a Pojo object in an indeterminate situation, in order to change its state to the present state when the object is present, and to persist it if it does not exist, that is to say, whatever it is, to have this object.
Save is the primary key that returns the inserted data, and saveorupdate is void
The Save method is more suitable for determining the primary key that is to be inserted and to get the inserted data
And Saveorupdate is more inclined to be unsure whether to insert or update, and you don't need to get his primary key
On the other hand, if you are unsure whether the object you want to insert or update is not persistent or free State. If you save a persistent state or update a Free State, this is problematic, and you need to use Saveorupdate
Overall, if you can determine the state of the object you are about to manipulate, you do not need to use saveorupdate
What is the difference between Hibernate's Saveorupdate (), Save (), and update ()?