Hello Folks,
I got this below error in my process. I am not updating anything in the process. Please assist
An error occurred while trying to write to the entity "EMP_CASE " [id=916ee3cb-938e-4931-a61b-ba630fe5a543@61527, type=EMP_CASE (id=5350)] (data store: EMP Main DS). Details: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement: org.hibernate.exception.ConstraintViolationException: could not execute statement: java.sql.SQLIntegrityConstraintViolationException: (conn=7948467) Duplicate entry '229' for key 'EmpID': org.mariadb.jdbc.internal.util.exceptions.MariaDbSqlException: Duplicate entry '229' for key 'EmpID': java.sql.SQLException: Duplicate entry '229' for key 'EmpID' Data: TypedValue[it=5351,v={{<null>,229,eFront,89777,<null>,<null>,Open,0,TEST,Case,1,1,0,,1.0,56777,<null>,<null>,,,<null>,,<null>,,<null>,,<null>,,<null>,2024-09-16 17:43:20.39}}]
Discussion posts and replies are publicly visible
Hi Manjit,
I believe 'EmpID' is a foreign key in the 'EMP_CASE' table. If that's the case, could you verify whether a 'UNIQUE' key constraint has been added to this column? Since this is a one-to-many relationship, where multiple cases can be raised for an employee, the unique key constraint is not required and can be removed if it has been added
EmpID is unique key in this table. ID is autoincremented. It is unique also.
May I ask why the 'EmpID' is configured as a unique key column in the Employee case table? Since it is a unique key, it will prevent the insertion of case details with the same employee ID multiple times, meaning multiple cases cannot be created for or by the same employee. If the relationship is intended to be one-to-one, this makes sense. Otherwise, I would suggest removing the unique key constraint from the 'EmpID' column in the Employee case table.
Yes, this is a unique key in table. This is one to many relationship
One more thing, this didn't happen before. It starts throwing error suddenly
Okay, then you need to remove/delete the unique constraint from the 'EmpID' column in the 'EMP_CASE' table. It didn't happen before, and my guess is that you might not have created multiple cases for an employee.
yes, I didn't create before. But data is coming from somewhere else.
Deleting the unique constraint is the solution here, as it allows for the insertion of multiple cases for an employee, regardless of where the data is coming from.
Thank you so much. I will try to do this and get back to you.