openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garpinc <garp...@yahoo.com>
Subject Re: Duplicate entry issue with multithreaded application
Date Wed, 22 Aug 2012 23:18:30 GMT
I think above should work but in anycase if I change to AUTO id generation
then I get this exception instead which is a unique violation on an
alternate key for that table. It was looked up before in the transaction but
another thread also looked it up found it not to be there and performed the
same operation ahead of this thread's flush. So what can be done to address
this case? What I want is for that if there is a duplicate at time of insert
then it should resolve by requerying the object and using an instance of it
in place of the one it's trying to save. equals and hashcode are overridden.

Caused by: <openjpa-2.2.0-r422266:1244990 fatal store error>
org.apache.openjpa.persistence.EntityExistsException: Duplicate entry
'dca2db371c29a90789ba0bcbda5fc8a0808b4310-734f1c627a629e194f9ea9c' for key
'U_NZURTPK_URIHASH' {prepstmnt 317546907 INSERT INTO anzouritopk (pk,
datasetUri, datasetUriHash, persistedFully, typeUri, typeUriHash, uri,
uriHash) VALUES (?, ?, ?, ?, ?, ?, ?, ?) [params=(long) 5421, (Reader)
java.io.StringReader@1ea310d2, (String) N/A, (int) 0, (Reader)
java.io.StringReader@63a55ab4, (String)
734f1c627a629e194f9ea9cf0990bbaead59b188, (Reader)
java.io.StringReader@7ce61287, (String)
dca2db371c29a90789ba0bcbda5fc8a0808b4310]} [code=1062, state=23000]
FailedObject:
com.cambridgesemantics.anzo.relationalreplicator.jpa.model.AnzoURIToPKImpl@627e3c5f
	at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4903)
	at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4878)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:78)
	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:143)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:79)
	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:99)
	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:87)
	at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:357)
	at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flushGraph(ConstraintUpdateManager.java:349)
	at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:97)
	at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)
	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:713)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
	at
org.apache.openjpa.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:661)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
	... 19 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Duplicate
entry 'dca2db371c29a90789ba0bcbda5fc8a0808b4310-734f1c627a629e194f9ea9c' for
key 'U_NZURTPK_URIHASH' {prepstmnt 317546907 INSERT INTO anzouritopk (pk,
datasetUri, datasetUriHash, persistedFully, typeUri, typeUriHash, uri,
uriHash) VALUES (?, ?, ?, ?, ?, ?, ?, ?) [params=(long) 5421, (Reader)
java.io.StringReader@1ea310d2, (String) N/A, (int) 0, (Reader)
java.io.StringReader@63a55ab4, (String)
734f1c627a629e194f9ea9cf0990bbaead59b188, (Reader)
java.io.StringReader@7ce61287, (String)
dca2db371c29a90789ba0bcbda5fc8a0808b4310]} [code=1062, state=23000]
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:247)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:223)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:72)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1162)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:272)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1741)
	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:267)
	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:118)
	... 32 more




--
View this message in context: http://openjpa.208410.n2.nabble.com/Duplicate-entry-issue-with-multithreaded-application-tp7580917p7580918.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message