|
Michelle Caisse made changes - 18/Nov/05 06:55 AM
Michelle Caisse made changes - 18/Nov/05 07:44 AM
Michelle Caisse made changes - 18/Nov/05 08:21 AM
The patch seems right. What the JDO implementation has to do is to recognize that the primary key (if needed) for the join table must be a composite key consisting of the key referencing the owning table and id column from the mapped key. For example,
CREATE TABLE SET_OF_OBJECT0 ( IDENTIFIER INTEGER REFERENCES SET_COLLECTIONS NOT NULL, OBJREF BIGINT REFERENCES SIMPLE_CLASS NOT NULL ); The primary key for this table (if it is needed by the implementation -- let's discuss this) would be IDENTIFIER plus OBJREF. CREATE TABLE SET_OF_OBJECT1 ( IDENTIFIER INTEGER REFERENCES SET_COLLECTIONS NOT NULL, ID BIGINT NOT NULL, INTVAL INTEGER NOT NULL, STRINGVAL VARCHAR(128) NOT NULL ); The primary key for this table would be IDENTIFIER plus ID. This appears to be a JPOX issue assuming an column that doesn't exist.
Michelle Caisse made changes - 19/Nov/05 02:14 AM
Craig Russell made changes - 19/Nov/05 02:14 AM
Committed patch with revision 345614
I see that the MetaData is now, for example
<field name="HashSetOfObject1" table="HASHSET_OF_OBJECT1"> <join column="IDENTIFIER"/> <element> <embedded> <field name="id" primary-key="true" column="ID"/> <field name="intField" column="INTVAL"/> <field name="stringField" column="STRINGVAL"/> </embedded> </element> </field> That certainly doesnt agree with my definition of a PK specification for the join table. It should be (IMHO) like this <join> <primary-key> <column name="IDENTIFIER"/> <column name="ID"/> </primary-key> </join> which nicely defines the colums to be used for the join table. Using fields of an embedded object and specifying primary-key there is not logical to me, and not supported by JPOX either. The JPOX online docs http://www.jpox.org/docs/1_1/constraints.html provides what we support for PK definition, which is that above. This is the same issue as
<field name="HashSetOfObject1" table="HASHSET_OF_OBJECT1"> <join column="IDENTIFIER"> <primary-key> <column name="IDENTIFIER"/> <column name="ID"/> </primary-key> </join> <element> <embedded> <field name="id" column="ID"/> <field name="intField" column="INTVAL"/> <field name="stringField" column="STRINGVAL"/> </embedded> </element> </field>
Craig Russell made changes - 22/Nov/05 04:51 AM
As discussed on the JDO expert group, the primary-key annotation is only needed for cases where there is an embedded Map key or Set element that doesn't have a unique key field already known. That is, for embedded SimpleClass with datastore identity used as Map keys or Set elements. The other cases have a known unique field that can be used to make the rows unique. For embedded SimpleClass with appication identity, it's the id field. For non-embedded SimpleClass, it's the foreign key reference.
I believe this is now a dup of
Michelle Caisse made changes - 02/Dec/05 09:24 AM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The two tests fail with the patch applied. Both application and datastore identity fail, but on different columns.
[java] test(org.apache.jdo.tck.models.fieldtypes.TestHashSetCollections)javax.jdo.JDODataStoreException: Add request failed : INSERT INTO datastoreidentity0.HASHSET_OF_OBJECT1 (IDENTIFIER,ID,INTVAL,STRINGVAL,ADPT_PK_IDX) VALUES (?,?,?,?,?)
[java] FailedObject:[Ljava.lang.Object;@1e22c75
[java] at org.jpox.store.rdbms.scostore.NormalSetStore.addAll(NormalSetStore.java:657)
[java] at org.jpox.store.mapping.CollectionMapping.postUpdate(CollectionMapping.java:281)
[java] at org.jpox.store.rdbms.request.UpdateRequest.execute(UpdateRequest.java:282)
[java] at org.jpox.store.rdbms.table.ClassTable.update(ClassTable.java:1931)
[java] at org.jpox.store.StoreManager.update(StoreManager.java:780)
[java] at org.jpox.state.StateManagerImpl.flush(StateManagerImpl.java:4336)
[java] at org.jpox.state.StateManagerImpl.runReachability(StateManagerImpl.java:3099)
[java] at org.jpox.AbstractPersistenceManager.preCommit(AbstractPersistenceManager.java:3110)
[java] at org.jpox.NonmanagedTransaction.commit(NonmanagedTransaction.java:420)
[java] at org.apache.jdo.tck.models.fieldtypes.TestHashSetCollections.runTest(TestHashSetCollections.java:96)
[java] at org.apache.jdo.tck.models.fieldtypes.TestHashSetCollections.test(TestHashSetCollections.java:75)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:204)
[java] at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
[java] at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)
[java] test(org.apache.jdo.tck.models.fieldtypes.TestHashSetCollections)javax.jdo.JDODataStoreException: Add request failed : INSERT INTO applicationidentity0.HASHSET_OF_OBJECT2 (IDENTIFIER,COLLVAL,ADPT_PK_IDX) VALUES (?,?,?)
[java] FailedObject:[Ljava.lang.Object;@56182f
[java] at org.jpox.store.rdbms.scostore.NormalSetStore.addAll(NormalSetStore.java:657)
[java] at org.jpox.store.mapping.CollectionMapping.postUpdate(CollectionMapping.java:281)
[java] at org.jpox.store.rdbms.request.UpdateRequest.execute(UpdateRequest.java:282)
[java] at org.jpox.store.rdbms.table.ClassTable.update(ClassTable.java:1931)
[java] at org.jpox.store.StoreManager.update(StoreManager.java:780)
[java] at org.jpox.state.StateManagerImpl.flush(StateManagerImpl.java:4336)
[java] at org.jpox.state.StateManagerImpl.runReachability(StateManagerImpl.java:3099)
[java] at org.jpox.AbstractPersistenceManager.preCommit(AbstractPersistenceManager.java:3110)
[java] at org.jpox.NonmanagedTransaction.commit(NonmanagedTransaction.java:420)
[java] at org.apache.jdo.tck.models.fieldtypes.TestHashSetCollections.runTest(TestHashSetCollections.java:96)
[java] at org.apache.jdo.tck.models.fieldtypes.TestHashSetCollections.test(TestHashSetCollections.java:75)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:204)
[java] at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
[java] at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)