Hi all,
I have a class ProductGroup and two subclasses, ProteinProductGroup and BioToolProductGroup.. The only difference is that I want to map a set of products differently for each subclass using a differnt primary key. I could just copy the .hbm.xml for ProductGroup into each subclasses mapping file, but that seems wrong. Here is what I tried:
Code:
<class name="com.upstate.catalog.om.ProductGroup" table="Product_Groups" dynamic-update="true"
proxy="com.upstate.catalog.om.ProductGroup">
<id name="id" type="int" column="Product_Group_ID" unsaved-value="0">
<generator class="native"/>
</id>
<property name="name" column="Name" type="string"/>
<property name="description" column="Description" type="string"/>
<subclass name="com.upstate.catalog.om.ProteinProductGroup" lazy="true" proxy="com.upstate.catalog.om.ProteinProductGroup">
<set name="products" lazy="true">
<key column="Protein_Product_Group_ID"/>
<one-to-many class="com.upstate.catalog.om.product.HibernateProduct" />
</set>
</subclass>
<subclass name="com.upstate.catalog.om.BiotoolProductGroup" lazy="true" proxy="com.upstate.catalog.om.BiotoolProductGroup">
<set name="products" lazy="true">
<key column="Biotool_Product_Group_ID"/>
<one-to-many class="com.upstate.catalog.om.product.HibernateProduct" />
</set>
</subclass>
</class>
Unfortunantly I don't have a discriminator in table Product_Group to distingush between them.. The only difference is their fk's in the product table. I couldn't figure out from the 3 strategies page (
http://www.hibernate.org/hib_docs/refer ... ritance-s1) which one to use...