Hello,

I am facing an issue when trying to retrieve the Drawer object.
Instead of retrieving a collection of Toy and Book instances in the 
stuffInDrawer attribute, collection containing Thing instances is returned.

Following is the class descriptor that is used.

<class-descriptor
    class="Thing"
    table="THINGS">

   <extent-class class-ref="Toy"/>
   <extent-class class-ref="Book"/>

    <field-descriptor
        name="id"
        column="ID"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
        />

    <field-descriptor
        name="name"
        column="NAME"
        jdbc-type="VARCHAR"
        size="255"
        />

    <field-descriptor
        name="drawerId"
        column="DRAWER_ID"
        jdbc-type="INTEGER"
        access="anonymous"
        />

</class-descriptor>

<class-descriptor
    class="Toy"
    table="TOYS">

    <field-descriptor
        name="id"
        column="ID"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
        />

    <field-descriptor
        name="category"
        column="CATEGORY"
        jdbc-type="VARCHAR"
        size="255"
        />

    <field-descriptor
        name="parentThingId"
        column="THING_ID"
        jdbc-type="BIGINT"
        access="anonymous"
    >
    </field-descriptor>

    <reference-descriptor
        name="super"
        class-ref="Thing"
    >
        <foreignkey field-ref="parentThingId"/>
    </reference-descriptor>

</class-descriptor>

<class-descriptor
    class="Book"
    table="BOOKS">

    <field-descriptor
        name="id"
        column="ID"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
        />

    <field-descriptor
        name="author"
        column="AUTHOR"
        jdbc-type="VARCHAR"
        size="255"
        />

    <field-descriptor
        name="isbnCode"
        column="ISBN_CODE"
        jdbc-type="VARCHAR"
        size="255"
        />

    <field-descriptor
        name="parentThingId"
        column="THING_ID"
        jdbc-type="BIGINT"
        access="anonymous"
    >
    </field-descriptor>

    <reference-descriptor
        name="super"
        class-ref="Thing"
    >
        <foreignkey field-ref="parentThingId"/>
    </reference-descriptor>

</class-descriptor>


<class-descriptor
    class="Drawer"
    table="DRAWER">

    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
        />
    
    <collection-descriptor
        name="stuffInDrawer"
        element-class-ref="Thing"
        >
        <inverse-foreignkey field-ref="drawerId"/>
    </collection-descriptor>
</class-descriptor>


I have used the table per subclass hierarchy strategy.
I have used SequenceManagerHighLowImpl as the sequence manager. The ids (ID 
column) in the TOYS and BOOKS tables are unique when the Drawer object is 
stored. In the sense, when a Drawer containing 3 things (2 books and 1 toy) is 
stored, the ids stored in THINGS table are 1, 2, and 3, where as the ids stored 
in BOOKS table are 1 and 2 and id stored in the TOYS table is 3.

I hope I have provided sufficient details to debug the issue. Could anyone 
please point me as to where am I going wrong or if there is any way to 
circumvent the problem ?
 
Thanks and Regards,
Gautam.


 

Reply via email to