lrow commented on Bug HHH-1268

Hi ,
Is there any solution for this ?

I have many to many relationshio between parent and message table and a mapping table parentmessage which has
combination of parent's primary key + message primary key .

For a foreignid 1000003554 . I am removing a message with id 4334 (element at list index 2 ) from parent and then updating the parent .
I debugged List of messages in the parent object before update call . [i.e. it reflects that one message element is removed from the List of messages. ]

However while saving, Hibernate throws following exception stating the next element in the collection already exists in the database .

Caused by: org.hibernate.exception.ConstraintViolationException: ERROR: duplicate key value violates unique constraint "parentmessage_pkey"
Detail: Key (foreignid, messageid)=(1000003554, 4335) already exists.

In this scenario next element is message with id 4335 (element at list index 3 ) .

Data ( parentmessage table )
foreignid messageid listindex
1000003554 4133 0
1000003554 4326 1
1000003554 4334 2
1000003554 4335 3
1000003554 4338 4
1000003554 4655 5
1000003554 4656 6

Just for troubleshooting I tried deleting the element at last index (index '6' in above case ) and it worked fine .

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira