Do a search on "bi-directional" relationships on the mailing list.  I'm not
an expert on Castor, but I believe you will need another field that
specifies that the superior product has many subordinates.  Right now, your
mapping only specifies that a subordinate has one superior.  I hope that
helps.


-----Original Message-----
From: Enrico Thor [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 08, 2002 10:55 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Hierarchies within one class/table


Hi All,

I have the following situation:

Imagine I want to create a product-hierarchy, so I would have a class
Product which has a Link to another object of class Product. The
corresponding database-table also has a foreign key linking to a primary
key of the same table. The mapping file just looks like any
1:n-relationship except that it links to the same class the mapping is
provided for:

    <class name="com.foo.Product" identity="id"
      key-generator="product">
        <cache-type type="none"/>
        <map-to table="PRODUCT"/>
        <field name="name" type="java.lang.String">
            <sql name="NAME" type="varchar"/>
        </field>
        <field name="id" type="long">
            <sql name="ID" type="integer"/>
        </field>
>>
        <field name="superiorProduct"
          type="com.foo.Product">
            <sql name="PRODUCT_ID" />
        </field>
>>
    </class>
</mapping>

My problem now is, that castor does not complain at all, but the
database column for the superiorProduct is not inserted nor updated.

Can anyone help?

Thanks in advance.

Enrico

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

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

Reply via email to