Hi.  I have a one-to-many relationship where the identity of the many-table
is the same column that should act as the foreign key.  The problem is that
Castor seems to force me to define another column to act as the foreign
key.  It does not seem to allow for the same column to be used as both, the
identity and the foreign key.  Please see my mapping file below.  This is
the only way I could get it to work.  Has anyone done this before without
having to define a special column?

<?xml version="1.0"?>
<mapping>

<class name="org.frb.ny.security.User" identity="uid">
  <map-to table="CUT_RPT_USERS"/>
  <field name="uid" type="string">
    <sql name="uid" type="varchar"/>
  </field>
  <field name="firstName" type="string">
    <sql name="f_name" type="varchar"/>
  </field>
  <field name="lastName" type="string">
      <sql name="l_name" type="varchar"/>
  </field>
  <field name="attributes" type="org.frb.ny.security.UserAttribute"
collection="arraylist">
    <sql many-key="id_user"/>  <!-- This refers to the new column I had to
add -->
  </field>
</class>



<class name="org.frb.ny.security.UserAttribute" identity="uid attrName"
depends="org.frb.ny.security.User">
  <map-to table="CUT_RPT_USER_ATTRS"/>
  <field name="uid" type="string">
    <sql name="uid" type="varchar"/>
  </field>
  <field name="user" type="org.frb.ny.security.User" required="true">
    <sql name="id_user"/>  <!-- This is the column that I needed to add.
In reality, it's the same as the uid column -->
  </field>
  <field name="attrName" type="string">
    <sql name="attr_name" type="varchar"/>
  </field>
  <field name="attrValue" type="string">
    <sql name="attr_value" type="varchar"/>
  </field>

</class>

</mapping>

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

Reply via email to