I have an abstract superclass called EntityAbstract that has an Address, and
various subclasses of EntityAbstract such as Licensor.  In the mapping, I
have added Address as an attribute of Licensor.  Since there is a (well known)
bug when populating the foreign keys in unidirectional independent 1:M
relationships, I of course encounter that.  I can't make Address dependent on
more than one master object (all the EntityAbstract subclasses) per the
documentation.  I also can't make the relationship bidrectional since the
Address mapping would need to point to each of the subclasses as well.  Am I
incorrect in my assumptions?  Any ideas on how to make this work until the
bug described above is fixed?  Or a quick fix for the bug?

Thanks in advance.

--
Chris Bonham
President/CEO
Third Eye Consulting, Inc.
[EMAIL PROTECTED]
http://www.thirdeyeconsulting.com
317.823.3686
317.823.0353 (FAX)

Database tables (MySQL 3.23):

CREATE TABLE Address(
address_id INT DEFAULT 0 NOT NULL AUTO_INCREMENT,
address_line_1 VARCHAR(30) NOT NULL,
address_line_2 VARCHAR(30),
city VARCHAR(30) NOT NULL,
state CHAR(2) NOT NULL,
postal_code VARCHAR(10) NOT NULL,
country CHAR(2) NOT NULL,
FOREIGN KEY (country) REFERENCES Country (code),
FOREIGN KEY (state) REFERENCES State (code),
PRIMARY KEY (address_id));

CREATE TABLE Licensor(
licensor_id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
address_id INT NOT NULL,
phone_num VARCHAR(15) NOT NULL,
fax_num VARCHAR(15),
website VARCHAR(30),
licensing_group_id INT NOT NULL,
required CHAR(1) DEFAULT 'N' NOT NULL,
FOREIGN KEY (licensing_group_id) REFERENCES Licensing_group (licensing_group_id),
FOREIGN KEY (address_id) REFERENCES Address (address_id),
PRIMARY KEY (licensor_id));

mapping.xml:

<!--  Mapping for Address  -->
  <class name="spi.server.businessobjects.AddressImpl"
         identity="id" key-generator="IDENTITY">
    <description>Address</description>
    <map-to table="Address" />
    <field name="id" type="integer" >
      <sql name="address_id" type="integer"/>
    </field>
    <field name="streetAddress1">
      <sql name="address_line_1"/>
    </field>
    <field name="streetAddress2">
      <sql name="address_line_2"/>
    </field>
    <field name="city">
      <sql name="city"/>
    </field>
    <field name="state" type="spi.domainobjects.State">
      <sql name="state"/>
    </field>
    <field name="postalCode">
      <sql name="postal_code"/>
    </field>
    <field name="country" type="spi.domainobjects.Country">
      <sql name="country"/>
    </field>
  </class>  

  <!--  Mapping for Licensor  -->
  <class name="spi.server.businessobjects.LicensorImpl"
         depends="spi.server.businessobjects.LicensingGroupImpl"
         identity="id" key-generator="IDENTITY">
    <description>Licensor</description>
    <map-to table="Licensor" />
    <field name="id" type="integer" >
      <sql name="licensor_id" type="integer"/>
    </field>
    <field name="name" type="string">
      <sql name="name" type="char" dirty="check" />
    </field>
    <field name="address" type="spi.server.businessobjects.AddressImpl">
      <sql name="address_id" />
    </field>
    <field name="phoneNumber" type="string">
      <sql name="phone_num" type="char" dirty="check" />
    </field>
    <field name="faxNumber" type="string">
      <sql name="fax_num" type="char" dirty="check" />
    </field>
    <field name="website" type="string">
      <sql name="website" type="char" dirty="check" />
    </field>
    <field name="licensingGroup" type="spi.server.businessobjects.LicensingGroupImpl">
      <sql name="licensing_group_id" />
    </field>
    <field name="required" type="boolean">
      <sql name="required" type="char[NY]" dirty="check" />
    </field>
  </class>

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

Reply via email to