Spring hibernatetemplate saveorupdate not updating
Hi all, I am new user of hibernate, and getting confused with the working of save Or Update().
I have read that save Or Update() will update the table entry if there is a record present for that ID, and if the id is not present then it simply insert the record. I have a Role Table like Role_id | Role_Name | Create_Time | Create_User | Update_Time | Update_USer1 Admin At null nullnow when from the UI when an update is happen, I just use this, they are set to null.
But In updation what i want to do is I Only want to update only those field which has been changed, e.g in my example only update_time and update_user will be changed, so only this columns should be updated not the create_user, and create_update query is also running and it is updating all the fields like,update role... The dynamic-update option only works when the entity was loaded by the session.
Hibernate must know the initial state, otherwise it can't detect which properties that has been changed.
The code below should work no matter what the dynamic-update or select-before-update has been set to.
There is a possibility that the following may work if dynamic-update has been enabled, but I am not 100% that there are no side-effects if things are more complicated than simple properties.
For example, I don't know what will happen with cascades to associations or collections.