Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumscached sql insert statement executed during query exection
https://www.eclipse.org/forums/index.php/mv/msg/171031/543692/#msg_543692
The entity manager operations are synchronized to make sure that there is only one thread using the entity manager at a time.
Two threads running in parallel, one writing the records and the other executing sql query to get the data from the database using same entity manager.
The two threads are synchronized so once the writing operation is completed the query gets the executed. This could see from the eclipselink detailed log info that there is no overlapping in sql instructions.
The problem is when executing the sql query, the inerst sql instructions from previously executed statements get cached and executed for the second time and resulting in
Internal Exception: java.sql.BatchUpdateException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL100629211102660' defined on 'TEST'.
Error Code: 20000
Query: ReportQuery(referenceClass=Entry sql="SELECT COUNT(t0.ENTRY_ID) FROM ENTRY t0, PRTY t2, TEST t1 WHERE (((LCASE(t1.PATH) LIKE ?) AND (UCASE(t2.PRTY) LIKE ?)) AND ((t1.L_ID = t0.L_ID) AND (t2.PRTY = t0.TEST_ID)))")
Caused by: org.eclipse.persistence.exceptions.DatabaseException:
Internal Exception: java.sql.BatchUpdateException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL100629211102660' defined on
]]>vuswati 2010-06-30T10:31:57-00:00Re: cached sql insert statement executed during query exection
https://www.eclipse.org/forums/index.php/mv/msg/171031/543736/#msg_543736
Can you post the full stack trace? Also, try turning on EclipseLink logging and post the log from the writing thread perform the same statement upto the read query error on the other thread. This might indicate a reason why it thinks it should reissue the statement. Are there any errors in the writing thread that might have been silently ignored?
Best Regards,
Chris]]>Chris Delahunt2010-06-30T12:53:47-00:00Re: cached sql insert statement executed during query exection
https://www.eclipse.org/forums/index.php/mv/msg/171031/543786/#msg_543786
If I remember there were no error info during the write operation.
One more thing is if write operation is failed for some reason, then how is it possible that the records are added to the database.]]>vuswati 2010-06-30T14:51:27-00:00Re: cached sql insert statement executed during query exection
https://www.eclipse.org/forums/index.php/mv/msg/171031/544387/#msg_544387
How are you managing transactions in this synchronized EntityManager?
Best Regards,
Chris]]>Chris Delahunt2010-07-02T14:19:38-00:00