I am trying to update data and as I know save() method saves entity if the id is null or update an existing entity in the database if the given id is found in DB.
Howeve
Your Entity Employer
looks to be in detached/Transient state and you are passing id
value manually which is not permitted, as it is marked as @GeneratedValue(strategy = GenerationType.IDENTITY)
.
What you need to do is when you know the primary key value i.e id
value, first you fetch the Entity from the database using findById() method, by which Entity comes into Managed state and then try to update the Entity by calling save() method. This will update your Entity.
For more info on Entity state you can refer this: https://vladmihalcea.com/a-beginners-guide-to-jpa-hibernate-entity-state-transitions/