Bug 300788 - When using eclipse events and doing a delete the commit is skipped
Summary: When using eclipse events and doing a delete the commit is skipped
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 313113 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-26 06:05 EST by Tom Eugelink CLA
Modified: 2022-06-09 10:33 EDT (History)
1 user (show)

See Also:


Attachments
java source directory with test case (8.66 KB, application/octet-stream)
2010-01-26 06:24 EST, Tom Eugelink CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Eugelink CLA 2010-01-26 06:05:24 EST
Build Identifier: 2.0.0

This is a complex problem, but it is reproducible.
- there are two entities in a master detail relation
- on the child relation an eclipse "postDelete" event is present
- this event gets there by adding a listener to the event manager of the class descriptor and that routes the event to the entity (emulating JPA @events)
- the jdbc connection runs in a delayed constrained mode, checking the on commit. 
- In order to do this, a custom jdbc driver and connection implementation is used that executes a "set constraints all deferred" on the appropriate moments

When the master is deleted, the foreign key of the child results in an exception upon commit. However, if the postDelete method executes a native query the commit is never called! All connections are just closed.

In the attached zip a totally stripped example is present. This is the output without the event method:

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Key value for constraint (informix.u208_344) is still being referenced.
Error Code: -692
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicCommitTransaction(DatabaseAccessor.java:420)
...
[EL Finest]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Thread(Thread[main,5,main])--Begin undeploying Persistence Unit reinders; session reinders_url=jdbc:reinders:com.informix.jdbc.IfxDriver#jdbc:informix-sqli://toeu_reinders:9088/reinders:INFORMIXSERVER=ol_ids_1150_1;DB_LOCALE=en_us.utf8_user=user; state Deployed; factoryCount 1
[EL Config]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Connection(9703298)--Thread(Thread[main,5,main])--disconnect
[EL Finest]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Thread(Thread[main,5,main])--sequencing disconnected
[EL Config]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Connection(23953814)--Thread(Thread[main,5,main])--disconnect
[EL Finer]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Thread(Thread[main,5,main])--initialize identitymaps
[EL Info]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Thread(Thread[main,5,main])--reinders_url=jdbc:reinders:com.informix.jdbc.IfxDriver#jdbc:informix-sqli://toeu_reinders:9088/reinders:INFORMIXSERVER=ol_ids_1150_1;DB_LOCALE=en_us.utf8_user=user logout successful
[EL Config]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Connection(17605128)--Thread(Thread[main,5,main])--disconnect
[EL Config]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Connection(5910186)--Thread(Thread[main,5,main])--disconnect
[EL Finest]: 2010-01-15 16:55:10.281--ServerSession(14008569)--Thread(Thread[main,5,main])--End undeploying Persistence Unit reinders; session reinders_url=jdbc:reinders:com.informix.jdbc.IfxDriver#jdbc:informix-sqli://toeu_reinders:9088/reinders:INFORMIXSERVER=ol_ids_1150_1;DB_LOCALE=en_us.utf8_user=user; state Undeployed; factoryCount 


and this with the event method:

[EL Fine]: 2010-01-15 16:52:32.125--ClientSession(6767312)--Connection(5910186)--Thread(Thread[main,5,main])--DELETE FROM batchtransfer WHERE ((batchtransfernr = ?) AND (lazylock = ?))
    bind => [18, 1]
[EL Finer]: 2010-01-15 16:52:32.171--UnitOfWork(23747954)--Thread(Thread[main,5,main])--end unit of work commit
[EL Finer]: 2010-01-15 16:52:32.171--UnitOfWork(23747954)--Thread(Thread[main,5,main])--resume unit of work
[EL Finer]: 2010-01-15 16:52:32.171--UnitOfWork(23747954)--Thread(Thread[main,5,main])--release unit of work
[EL Finer]: 2010-01-15 16:52:32.171--ClientSession(6767312)--Thread(Thread[main,5,main])--client released
[EL Finest]: 2010-01-15 16:52:32.171--ServerSession(14008569)--Thread(Thread[main,5,main])--Begin undeploying Persistence Unit reinders; session reinders_url=jdbc:reinders:com.informix.jdbc.IfxDriver#jdbc:informix-sqli://toeu_reinders:9088/reinders:INFORMIXSERVER=ol_ids_1150_1;DB_LOCALE=en_us.utf8_user=user; state Deployed; factoryCount 1
[EL Config]: 2010-01-15 16:52:32.171--ServerSession(14008569)--Connection(9703298)--Thread(Thread[main,5,main])--disconnect
[EL Finest]: 2010-01-15 16:52:32.171--ServerSession(14008569)--Thread(Thread[main,5,main])--sequencing disconnected
[EL Config]: 2010-01-15 16:52:32.171--ServerSession(14008569)--Connection(23953814)--Thread(Thread[main,5,main])--disconnect
[EL Finer]: 2010-01-15 16:52:32.171--ServerSession(14008569)--Thread(Thread[main,5,main])--initialize identitymaps
[EL Info]: 2010-01-15 16:52:32.171--ServerSession(14008569)--Thread(Thread[main,5,main])--reinders_url=jdbc:reinders:com.informix.jdbc.IfxDriver#jdbc:informix-sqli://toeu_reinders:9088/reinders:INFORMIXSERVER=ol_ids_1150_1;DB_LOCALE=en_us.utf8_user=user logout successful
[EL Config]: 2010-01-15 16:52:32.171--ServerSession(14008569)--Connection(17605128)--Thread(Thread[main,5,main])--disconnect
[EL Config]: 2010-01-15 16:52:32.171--ServerSession(14008569)--Connection(5910186)--Thread(Thread[main,5,main])--disconnect
[EL Finest]: 2010-01-15 16:52:32.203--ServerSession(14008569)--Thread(Thread[main,5,main])--End undeploying Persistence Unit reinders; session reinders_url=jdbc:reinders:com.informix.jdbc.IfxDriver#jdbc:informix-sqli://toeu_reinders:9088/reinders:INFORMIXSERVER=ol_ids_1150_1;DB_LOCALE=en_us.utf8_user=user; state Undeployed; factoryCount 0 


There is a thread in the newsgroup titled "2.0.0: where did the commit go?"



Reproducible: Always
Comment 1 Tom Eugelink CLA 2010-01-26 06:24:37 EST
Created attachment 157235 [details]
java source directory with test case
Comment 2 Tom Eugelink CLA 2010-01-26 06:32:09 EST
Reproducing it will depend on the deferred constraints; in normal operation the process already aborts in the sql delete, since the constraint intercepts that immediately and execution never reaches the postDelete.
Comment 3 Tom Ware CLA 2010-02-08 09:32:26 EST
Setting target and priority.  See the following page for details of what those values mean: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 4 Tom Eugelink CLA 2010-05-17 08:05:04 EDT
Still valid for 2.0.2
Comment 5 Tom Ware CLA 2010-05-28 15:06:18 EDT
*** Bug 313113 has been marked as a duplicate of this bug. ***
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:33:15 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink