You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Stephan Wannenwetsch <wa...@reitec.de> on 2003/12/15 11:15:56 UTC
Mapping problem
Hallo,
I've got a problem retrieving objects from a m:n relationship:
Object model:
class Supplier;
=>Collection items;
Interface SellableItem;
=>Collection suppliers;
class Product implements SellableItem;
=> Collection suppliers;
class ServiceContract implements SellableItem;
=> Collection suppliers;
Of course there are some more attributes in each class with the
corresponding getter and setters.
I use an itermediate table OJB_SUPPLIER_ITEM to realise the m:n
relationship.
Every thing works fine coming from the supplier side and retriving the
related items of a supplier but I'm not able to retrieve the related
suppliers of an item.
I hope someone can help me.
Thanks,
Stephan
Mapping:
<class-descriptor
class="demo.myshop.model.ojb2.Supplier"
table="OJB_SUPPLIER">
<field-descriptor
name="fk_bpid"
column="FK_BPID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="false"
access="anonymous"/>
<field-descriptor
name="shippingCost"
column="SHIPPINGCOST"
jdbc-type="INTEGER"/>
<reference-descriptor
name="businessPartner"
class-ref="demo.myshop.model.ojb2.BusinessPartner">
<foreignkey field-ref="fk_bpid"/>
</reference-descriptor>
<collection-descriptor
name="items"
element-class-ref="demo.myshop.model.ojb2.SellableItem"
auto-retrieve="true"
auto-update="true"
indirection-table="OJB_SUPPLIER_ITEM">
<fk-pointing-to-this-class column="SUPPLIERID"/>
<fk-pointing-to-element-class column="ITEMID"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor
class="demo.myshop.model.ojb2.SellableItem"
table="OJB_SELLABLEITEM">
<extent-class class-ref="demo.myshop.model.ojb2.ServiceContract"
/>
<extent-class class-ref="demo.myshop.model.ojb2.Product" />
<field-descriptor
name="itemId"
column="ITEMID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"/>
<field-descriptor
name="ojbConcreteClass"
column="CLASS_NAME"
jdbc-type="VARCHAR"/>
<field-descriptor
name="description"
column="DESCRIPTION"
jdbc-type="VARCHAR"/>
<field-descriptor
name="price"
column="PRICE"
jdbc-type="INTEGER"/>
<collection-descriptor
name="suppliers"
element-class-ref="demo.myshop.model.ojb2.Supplier"
auto-retrieve="true"
auto-update="true"
indirection-table="OJB_SUPPLIER_ITEM">
<fk-pointing-to-this-class column="ITEMID"/>
<fk-pointing-to-element-class column="SUPPLIERID"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor
class="demo.myshop.model.ojb2.ServiceContract"
table="OJB_SELLABLEITEM">
<field-descriptor
name="itemId"
column="ITEMID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"/>
<field-descriptor
name="ojbConcreteClass"
column="CLASS_NAME"
jdbc-type="VARCHAR"/>
<field-descriptor
name="description"
column="DESCRIPTION"
jdbc-type="VARCHAR"/>
<field-descriptor
name="price"
column="PRICE"
jdbc-type="INTEGER"/>
<field-descriptor
name="period"
column="PERIOD"
jdbc-type="INTEGER"/>
</class-descriptor>
<class-descriptor
class="demo.myshop.model.ojb2.Product"
table="OJB_SELLABLEITEM">
<field-descriptor
name="itemId"
column="ITEMID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"/>
<field-descriptor
name="ojbConcreteClass"
column="CLASS_NAME"
jdbc-type="VARCHAR"/>
<field-descriptor
name="description"
column="DESCRIPTION"
jdbc-type="VARCHAR"/>
<field-descriptor
name="price"
column="PRICE"
jdbc-type="INTEGER"/>
<field-descriptor
name="weight"
column="WEIGHT"
jdbc-type="INTEGER"/>
</class-descriptor>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org