Hi,

I'm having a problem creating a row in a table I've mapped to castor that
has a complex key with one of the columns being auto-increment:

CREATE TABLE dependent (
  Dependent_ID int(11) NOT NULL auto_increment,
  Patient_ID int(11) NOT NULL default '0',
  Age tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY  (Dependent_ID,Patient_ID)
) TYPE=MyISAM;

The mapping I'm using is:

    <class auto-complete="false" name="com.vioma.shs.castor.Dependent"
        access="shared" key-generator="IDENTITY" identity="dependent_ID
patient_ID">
        <description>Default mapping for class
com.vioma.shs.castor.Dependent</description>
        <map-to table="dependent" xml="dependent"/>
        <field required="true" transient="false" direct="false"
            name="dependent_ID" type="int" lazy="false">
            <sql name="Dependent_ID" dirty="check" type="integer"
read-only="false"/>
            <bind-xml node="attribute" name="Dependent_ID"/>
        </field>
        <field required="false" transient="false" direct="false"
            name="patient_ID" type="int" lazy="false">
            <sql name="Patient_ID" dirty="check" type="integer"
read-only="false"/>
            <bind-xml node="attribute" name="Patient_ID"/>
        </field>
        <field required="false" transient="false" direct="false"
            name="age" type="int" lazy="false">
            <sql name="Age" dirty="check" type="integer" read-only="false"/>
            <bind-xml node="attribute" name="Age"/>
        </field>
    </class>

If I set the Patient_ID and Age and leave the Dependent_ID to be generated,
I get the following exception:

testTables(com.vioma.shs.castor.CastorTests)org.exolab.castor.jdo.Persistenc
eException: The identity of a data object of type
com.vioma.shs.castor.Dependent, has been changed from 5 to null since it is
loaded/create/update.
        at
org.exolab.castor.persist.ClassMolder.preStore(ClassMolder.java:1148)
        at
org.exolab.castor.persist.LockEngine.preStore(LockEngine.java:723)
        at
org.exolab.castor.persist.TransactionContext.prepare(TransactionContext.java
:1462)
        at
org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:528)
        at com.vioma.shs.castor.CastorTests.testTables(CastorTests.java:203)

A row is created in the table with a unique dependent_ID, but the Patient_ID
is always replaced by a '0'.  Is it possible to use keygeneration with such
a primary key?

Thanks,
-Tom

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to