Issue Details (XML | Word | Printable)

Key: JDO-215
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Michelle Caisse
Reporter: Craig Russell
Votes: 0
Watchers: 0
Operations

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

Remove <order> from mapping for HashSetCollections and SetCollections.

Created: 17/Nov/05 06:29 AM   Updated: 02/Dec/05 09:24 AM
Return to search
Component/s: tck2
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works JDO-215.patch 2005-11-18 08:21 AM Michelle Caisse 61 kB

Resolution Date: 02/Dec/05 09:24 AM


 Description  « Hide
The mapping for HashSetCollections and SetCollections incorrectly have <order> columns.

There should not be an ordering specified for the join table since duplicates are not allowed. The mapping for application identity should not need a primary key, since the JDO implementation should be able to figure out that the primary key is part of the Map.key, but the datastore identity mapping does need a primary key (and again, I'd use the id field of SimpleClass as the join table key column.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michelle Caisse made changes - 18/Nov/05 06:55 AM
Field Original Value New Value
Assignee Michelle Caisse [ mcaisse ]
Michelle Caisse made changes - 18/Nov/05 07:44 AM
Status Open [ 1 ] In Progress [ 3 ]
Michelle Caisse added a comment - 18/Nov/05 08:21 AM
The attached patch removes the ALLOW_DUPLICATES order column from the orm metadata and schema for HashSetCollections and Set Collections for both application and datastore identity. It also adds a primary-key="true" attribute to the id column of join tables for SimpleClass in the orm metadata.

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)

Michelle Caisse made changes - 18/Nov/05 08:21 AM
Attachment JDO-215.patch [ 12320767 ]
Craig Russell added a comment - 18/Nov/05 08:58 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.

Repository Revision Date User Message
ASF #345614 Sat Nov 19 00:51:06 UTC 2005 mcaisse JDO-215
Files Changed
MODIFY /incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql
MODIFY /incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/HashSetCollections-derby.orm
MODIFY /incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/SetCollections-derby.orm
MODIFY /incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql
MODIFY /incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/HashSetCollections-derby.orm
MODIFY /incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/SetCollections-derby.orm

Craig Russell added a comment - 19/Nov/05 02:14 AM
This appears to be a JPOX issue assuming an column that doesn't exist.

Michelle Caisse made changes - 19/Nov/05 02:14 AM
Status In Progress [ 3 ] Open [ 1 ]
Craig Russell made changes - 19/Nov/05 02:14 AM
Assignee Michelle Caisse [ mcaisse ] Andy Jefferson [ andy ]
Michelle Caisse added a comment - 19/Nov/05 09:52 AM
Committed patch with revision 345614

Andy Jefferson added a comment - 22/Nov/05 03:54 AM
 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.

Craig Russell added a comment - 22/Nov/05 04:51 AM
This is the same issue as JDO-211. So I agree that the metadata should look like:

<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
Assignee Andy Jefferson [ andy ] Michelle Caisse [ mcaisse ]
Craig Russell added a comment - 24/Nov/05 09:29 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.

Repository Revision Date User Message
ASF #351537 Fri Dec 02 00:22:21 UTC 2005 mcaisse JDO-211, JDO-215
Files Changed
MODIFY /incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/MapStringValueCollections-derby.orm
MODIFY /incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringValueCollections-derby.orm
MODIFY /incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/HashMapStringValueCollections-derby.orm
MODIFY /incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/HashtableStringValueCollections-derby.orm
MODIFY /incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/HashMapStringKeyCollections.jdo

Michelle Caisse added a comment - 02/Dec/05 09:24 AM
I believe this is now a dup of JDO-211, thus resolved by revision 351537.

Michelle Caisse made changes - 02/Dec/05 09:24 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]