Issue Details (XML | Word | Printable)

Key: JDO-100
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Unassigned
Reporter: Michelle Caisse
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JDO

Insert request failed ... because it would have caused a duplicate key value

Created: 27/Jul/05 07:41 AM   Updated: 01/Nov/05 06:44 AM
Return to search
Component/s: tck2
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Resolution Date: 19/Aug/05 07:17 AM


 Description  « Hide
testSingleFieldIdentityInitializedDate and
testSingleFieldIdentityDate(org.apache.jdo.tck.api.persistencecapable.CopyKeyFieldsFromObjectId)javax.jdo.JDODataStoreException: Insert request failed: INSERT INTO applicationidentity0.PCPOINTSINGLEFIELDDATE (Y,X,ID) VALUES (?,?,?)
at org.jpox.store.rdbms.request.InsertRequest.execute(InsertRequest.java:329)
at org.jpox.store.rdbms.table.ClassTable.insert(ClassTable.java:1750)
at org.jpox.store.StoreManager.insert(StoreManager.java:663)
at org.jpox.state.StateManagerImpl.internalMakePersistent(StateManagerImpl.java:3090)
at org.jpox.state.StateManagerImpl.makePersistent(StateManagerImpl.java:3063)
at org.jpox.AbstractPersistenceManager.internalMakePersistent(AbstractPersistenceManager.java:1012)
at org.jpox.AbstractPersistenceManager.makePersistent(AbstractPersistenceManager.java:1048)
at org.apache.jdo.tck.api.persistencecapable.AbstractPersistenceCapableTest.makePersistent(AbstractPersistenceCapableTest.java:41)
at org.apache.jdo.tck.api.persistencecapable.CopyKeyFieldsFromObjectId.singleFieldIdentity(CopyKeyFieldsFromObjectId.java:156)
at org.apache.jdo.tck.api.persistencecapable.CopyKeyFieldsFromObjectId.testSingleFieldIdentityDate(CopyKeyFieldsFromObjectId.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:197)
at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:128)
at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:106)
NestedThrowablesStackTrace:
ERROR 23505: 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 'PCPNT_SFD_PK' defined on 'PCPOINTSINGLEFIELDDATE'.
at org.apache.derby.iapi.error.StandardException.newException(StandardException.java)
at org.apache.derby.impl.sql.execute.IndexChanger.insertAndCheckDups(IndexChanger.java)
at org.apache.derby.impl.sql.execute.IndexChanger.doInsert(IndexChanger.java)
at org.apache.derby.impl.sql.execute.IndexChanger.insert(IndexChanger.java)
at org.apache.derby.impl.sql.execute.IndexSetChanger.insert(IndexSetChanger.java)
at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java)
at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java)
at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:443)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michael Watzek added a comment - 11/Aug/05 02:15 AM
The duplicate key exception is thrown because there is an exception in a previous run during teardown preventing to delete the instance in the datastore.

That exception is a NoSuchMethodError thrown by the enhanced code (see below) of a class "PCPointSingleFieldDate" in methods "jdoCopyKeyFieldsFromObjectId". I decompiled the code of that class. It seems that the JPOX enhancer generates a java.util.Date constructor call that does not exist. This is an excerpt of the decompiled code:

    protected void jdoCopyKeyFieldsFromObjectId(Object oid)
    {
        if(!(oid instanceof ObjectIdentity))
        {
            throw new ClassCastException("key class is not javax.jdo.identity.ObjectIdentity or null");
        } else
        {
            ObjectIdentity o = (ObjectIdentity)oid;
            id = new Date(o.getKey());
            return;
        }
    }

However, there is also a bug in class "PCPointSingleFieldDate", which would result in a ClassCastException after the enhancer bug has been fixed:

     public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) {
- return this.id.equals(((StringIdentity)singleFieldIdentity).getKey());
+ return this.id.equals(((ObjectIdentity)singleFieldIdentity).getKey());
     }

    [java] 2) testSingleFieldIdentityInitializedDate(org.apache.jdo.tck.api.persistencecapable.NewObjectIdInstance)javax
.jdo.JDOFatalException: Exception during tearDown
    [java] at org.apache.jdo.tck.JDO_Test.tearDown(JDO_Test.java:281)
    [java] at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:211)
    [java] at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:128)
    [java] at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:106)
    [java] NestedThrowablesStackTrace:
    [java] java.lang.NoSuchMethodError: java.util.Date.<init>(Ljava/lang/Object;)V
    [java] at org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldDate.jdoCopyKeyFieldsFromObjectId(PCPoint
SingleFieldDate.java)
    [java] at org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldDate.jdoNewInstance(PCPointSingleFieldDat
e.java)
    [java] at javax.jdo.spi.JDOImplHelper.newInstance(JDOImplHelper.java:199)
    [java] at org.jpox.state.StateManagerImpl.<init>(StateManagerImpl.java:340)
    [java] at org.jpox.AbstractPersistenceManager.getObjectById(AbstractPersistenceManager.java:2322)
    [java] at org.jpox.AbstractPersistenceManager.getObjectById(AbstractPersistenceManager.java:2230)
    [java] at org.apache.jdo.tck.JDO_Test.deleteTearDownInstances(JDO_Test.java:336)
    [java] at org.apache.jdo.tck.JDO_Test.localTearDown(JDO_Test.java:292)
    [java] at org.apache.jdo.tck.JDO_Test.tearDown(JDO_Test.java:263)
    [java] at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:211)
    [java] at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:128)
    [java] at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:106)

Michael Watzek added a comment - 11/Aug/05 10:02 PM
I filed a new issue (JDO-118) for the class cast bug mentioned above.

Michelle Caisse added a comment - 19/Aug/05 07:17 AM
This issue appears to have been resolved.