Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #719070] Thu, 25 August 2011 22:24 Go to next message
Dave M is currently offline Dave MFriend
Messages: 20
Registered: July 2009
Junior Member
I have a unidirectional one-to-many that is causing problems. It is mapped using a join table (since it's unidirectional). The instance variable in the entity is typed as a Set. I have verified that the equals and hashCode methods of the entity whose instances are stored in that Set are well-behaved (i.e., the state on which they are based is not mutated after insertion into the Set, etc.). And I have inspected the Set of the offending entity at runtime and I don't see any duplicates.

The thing is....

When running with classes that have been statically woven I get the error shown below. When I turn weaving off the error no longer occurs.

Just wondering if anyone has an idea why that would be?

javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '3350-3379' for key 'PRIMARY'
Error Code: 1062
bind => [3379, 3350]
Query: DataModifyQuery(name="subgraphMembers" sql="INSERT INTO myschema.SUBGRAPH_MEMBERS (MEMBER_ID, SUBGRAPH_ID) VALUES (?, ?)")
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(


(no subject) [message #720543 is a reply to message #719070] Tue, 30 August 2011 19:11 Go to previous message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
There was an issue in EclipseLink that when change tracking is used, and calling add() on a lazy Set that had never been accessed, it would always try to add to the database, even if already contained in the Set.

I think this was fixed in the latest release. So try the latest release, or log a bug (should already be a bug, so if you find it vote for it).

The workaround is to just disable weaving of change tracking (or weaving entirely).
Or you can disable change tracking for just the one descriptor using @ChangeTracking.

Or you could ensure you access the Set first before the add(), by calling contains() first.

James : : :
Previous Topic:Duplicate key error only if classes are woven
Next Topic:Using views in CriteriaQuery
Goto Forum:

Current Time: Tue Oct 25 20:54:54 GMT 2016

Powered by FUDForum. Page generated in 0.03614 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software