The Save () method is obviously a save operation, and if you are saving a new newly-created object, you naturally use this method, which is not in the database.
Update () If you are updating a managed object that already exists, you must use the update () method, which is the object in the data.
Saveorupdate () This method is either updated or inserted, the primary key executes the update, and the insert is executed without a primary key.
Difference: For an object from a managed state to a transient (for an object that is removed from the database), the object itself has a primary key, but because it is deleted, this time because the record is not available in the database. But it also has a primary key exists, so this time can not use Update () or saveorupdate (), because the update () method is believed to have this record in the database, and saveorupdate is the execution of the first to see whether this object has a primary key, With the primary key then the update () method is executed, the Save () method is executed without the primary key, so the result is the same as the call to the update () method, and the result is an error because the object has been deleted and the record is not already in the database. It's just that it has a primary key (just in memory), so this is the Save () method.
The difference between save (), update (), Saveorupdate () in Hibernate