Can Castor support recursive relationships within a table?

I'm using MySQL and I have a table that looks like this:

CREATE TABLE Licensing_group(
licensing_group_id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
agency_id INT,
parent_licensing_group_id INT,
FOREIGN KEY (agency_id) REFERENCES Agency (agency_id),
FOREIGN KEY (parent_licensing_group_id) REFERENCES Licensing_group
(licensing_gr
oup_id),
PRIMARY KEY (licensing_group_id),
UNIQUE UC_licensing_group_id (licensing_group_id));

And the relevant mapping.xml portion looks like this:

  <!--  Mapping for LicensingGroup  -->
  <class name="spi.copyhelpers.LicensingGroupCopyHelper"
         identity="id" key-generator="IDENTITY">
    <description>LicensingGroup</description>
    <map-to table="Licensing_group" />
    <field name="id" type="integer" >
      <sql name="licensing_group_id" type="integer"/>
    </field>
    <field name="name" type="string">
      <sql name="name" type="char" dirty="check" />
    </field>
    <field name="agency" type="spi.copyhelpers.AgencyCopyHelper">
      <sql name="agency_id" />
    </field>
    <field name="parentLicensingGroup"
type="spi.copyhelpers.LicensingGroupCopyHelper">
      <sql name="parent_licensing_group_id" />
    </field>
    <field name="subGroups"
type="spi.copyhelpers.LicensingGroupCopyHelper"
           required="false" collection="vector">
      <sql many-key="licensing_group_id" />
    </field>
  </class>

The query generated by Castor throws an error:

SELECT
Licensing_group.name,Licensing_group.agency_id,Licensing_group.parent_licensing_group_id,Licensing_group.licensing_group_id
FROM Licensing_group LEFT OUTER JOIN Licensing_group ON
Licensing_group.licensing_group_id=Licensing_group.licensing_group_id
WHERE Licensing_group.licensing_group_id=?
ERROR 1066: Not unique table/alias: 'Licensing_group'

It appears that Castor is trying to join the table to itself, but it's
not using an alias.  Is this a bug or are recursive relationships not
supported?  Any suggestions on how to map this recursive relationship in
order to get around this problem?

Thanks.

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

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

Reply via email to