I think the issue you might be having is that you need to have a Primary Key
which is also a foreign key back into the same table.  Castor doesn't
support this currently.  

I have used a workaround which has worked in simple tests.  Forst specify
all the primary key fields in the mapping file.  Also specify a field for
the related object that is referenced (as a foreign key) by all or part of
the primary key within the same class.

Unfortunately I haven't done any testing with this workaround to see if
Castor properly handles the duplication of values/objects relying on the
same database fields.

Here is the message I sent to the list a couple of weeks ago...

-------------------

I have succesfully made this work with what seems to me a hack in the
mapping file.  I have the same database field appearing as separate java
fields in the mapping file.  This seems to work but would also require me to
write code in the java class which will keep the string key value and the
object reference value in synch.  

I would prefer to have Castor allow me to put a field name in the identity
which might be an object reference.  In 


Here is my hacked mapping file
------------------------------

<class naem="test1" identity="id">
    <field name="id" type="string">
    </field>
</class>

<class name="test2" identity="pk1 pk2">
    <map-to table="SDOPropertySet" xml="PropertySet"/>

    <field name="test1" type="test1" required="true">
        <sql name="pk1"/>
    </field>

    <field name="pk1" type="string" required="true">
        <sql name="pk1" type="varchar"/>
    </field>

    <field name="pk2" type="string" required="true">
          <sql name="pk2" type="varchar"/>
    </field>
</class>

Here is how I would prefer to do it
-----------------------------------

<class naem="test1" identity="id">
    <field name="id" type="string">
    </field>
</class>

<class name="test2" identity="test1 pk2">
    <map-to table="SDOPropertySet" xml="PropertySet"/>

    <field name="test1" type="test1" required="true">
        <sql name="pk1"/>
    </field>

    <field name="pk2" type="string" required="true">
          <sql name="pk2" type="varchar"/>
    </field>
</class>

-----Original Message-----
From: Sevin� Paul Ersin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 22, 2001 5:55 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] 


Hey y'all!

I'm currently evaluating Castor and want to realize a 1:n relationship
between companies (e.g., A owns B and C, and B owns D--companies are
organized in trees). I tried different table organizations and mappings, but
Castor seems to have trouble with the fact that a Company instance directly
manages Company instances.

My question is: How would your DB tables look and how your mapping XML file?


Thanks,
Paul

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

Reply via email to