Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #719070] Thu, 25 August 2011 18:24 Go to next message
Dave M is currently offline Dave M
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
Call: INSERT INTO myschema.SUBGRAPH_MEMBERS (MEMBER_ID, SUBGRAPH_ID) VALUES (?, ?)
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(EntityTransactionImpl.java:102)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)


Thanks,

Dave
(no subject) [message #720543 is a reply to message #719070] Tue, 30 August 2011 15:11 Go to previous message
James is currently offline James
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).
"eclipselink.weaving.changetracking"="false"
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 : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Previous Topic:Duplicate key error only if classes are woven
Next Topic:Using views in CriteriaQuery
Goto Forum:
  


Current Time: Thu Jul 24 13:55:38 EDT 2014

Powered by FUDForum. Page generated in 0.01447 seconds