Relative Content

Tag Archive for databasepostgresqlspring-boothibernatespring-data-jpa

Error modifying an entity in springboot : Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) :

In my spring boot application, I have an employe entity and a user entity , that are practically the same , just user has email and password so this entity is used only for authentication but this user references a specific employe so in database table user (id,email,password,employe_id) and employe(id,fname,lname,email,password,….,user_id) , and employe can be a manager or HR or just a simple employe so those are the role(id,role_name) and to associate each user with a role there is a join table user_role(user_id,role_id) , so this is my database structure now I am having issues when modifying information of an employee , changing the other fields goes normal but when it comes to changing role,which requires to delete a user then create a user with a different role then associate it with the modified employe :
this is the method that returns that error