|Determining when/why objects are registered with the EM / UOW [message #1098848]
||Sat, 31 August 2013 19:56
| Randy Tidd
Registered: August 2013
I am using EclipseLink 2.4.2 in a J2EE environment. We are debugging a problem whereby EclipseLink attemps to insert two objects which violate a database constraint because they have the same foreign key values.|
To briefly summarize the issue, there are two tables "A" and "B" with a many-to-many relationship between them, which in EclipseLink we have modeled as a separate table "AB" and associated Java class. There is a database constraint preventing the same two "A" and "B" objects from being associated more than once.
Looking at the SQL being output by EclipseLink at the flush(), it is trying to insert three rows into AB, two of which conflict. We are only intending on creating two objects, but a third is apparently created somewhere during the operation. The operation is a very complex batch operation with hundreds of rows of data processed by thousands of lines of code.
Somewhere throughout all of that code, a third instance of "AB" is being created and registered with the EntityManager, becomes part of the UnitOfWork, and is saved on the flush operation. However I am having difficulty in determining where or why that happens.
What I was hoping to find was either some API that I could call on the EntityManager or UnitOfWork to ask it when or how an object was registered, or a break point that I could set in the EclipseLink source code (which I have downloaded and integrated into my project) which would allow me to identify when the object was registered, so I could look up the stack and see what code in our system triggered this.
I feel that there must be some way of asking the EntityManager for its current set of dirty objects and operations, but haven't been able to find it. Thanks very much for any tips or advice.
Powered by FUDForum
. Page generated in 0.01692 seconds