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

post text "itemprop =" text ">

Get an ID to go straight to some ID generator DB Need to do

Example native MySQL when you save to the generator with an autoincrement column (). The phone will retrieve the display and the ID, even if you are not committed to the session

Try going into the managed generator from the hibernate.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -