Duplicate entry error in MySQL/Hibernate -
I am facing the following problem and can not find the appropriate solution I have property ID, x (foreign key) There is a relation with y (sequence number) and z (content). Apart from this, there is a specific disturbance on x-yy. I usually have tuples (455, 159, 1, ...), (456, 159, 2, ...), (457, 15 9, 3, ...) etc. I am using hibernate and it is a mapping table for a certain class. Now I have a case of use, where I want to insert a new object, or remove an already existing one and update the sequence number of other objects. For example, if I insert a new object after 1, then it should get the sequence number 2 and later the object that is 2 be 3, 3 should be 4, etc. Something like this should be done while removing the object - it should be the old 3 and 2, etc.
However, once an update has started I get a restriction violation.
Critical: The session could not synchronize the database state with org.hibernate.exception.ConstraintViolationException: java.sql.BatchUpdateException: could not execute Due to the JDBC batch update ... Duplicate Access '159- 2' for key 2
I can not explain why this happens why there is no commit / session flush, so although I was able to handle the hibernate / MySQL temporary inconsistency And will check the obstacles on committed. Is there anything I'm missing or really there is no way to do this without a major solution?
Cheers
Get an ID to go straight to some ID generator DB Need to do Example Try going into the managed generator from the hibernate.
Comments
Post a Comment