Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » cached sql insert statement executed during query exection
cached sql insert statement executed during query exection [message #543692] Wed, 30 June 2010 10:31 Go to next message
vuswati  is currently offline vuswati
Messages: 4
Registered: June 2010
Junior Member
Using eclipselink in extended persistent context mode, and using single entity manager for memory reason.

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

Re: cached sql insert statement executed during query exection [message #543736 is a reply to message #543692] Wed, 30 June 2010 12:53 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1023
Registered: July 2009
Senior Member
Hello,

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
Re: cached sql insert statement executed during query exection [message #543786 is a reply to message #543736] Wed, 30 June 2010 14:51 Go to previous messageGo to next message
vuswati  is currently offline vuswati
Messages: 4
Registered: June 2010
Junior Member
need to regenerate the log for detailed information, will attach it shortly.

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.
Re: cached sql insert statement executed during query exection [message #544387 is a reply to message #543786] Fri, 02 July 2010 14:19 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1023
Registered: July 2009
Senior Member
If the write failed an exception is thrown and the transaction should be marked for rollback. I have seen problems when JTA and datasources are not setup correctly where previous successful statements would be commited anyway, due to autocommit not being set to false. Cannot rule anything out without additional information.

How are you managing transactions in this synchronized EntityManager?

Best Regards,
Chris
Previous Topic:Moxy JAXB annotations for closure table relationship
Next Topic:Returning 1 member of a collection using jpql
Goto Forum:
  


Current Time: Tue Sep 23 00:28:55 GMT 2014

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

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