-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Mapping subclasses with out discriminator or seperate table?
PostPosted: Mon Feb 16, 2004 8:37 am 
Beginner
Beginner

Joined: Sat Dec 06, 2003 5:38 pm
Posts: 27
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...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 16, 2004 10:47 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't think you can if you've an unmodifiable legacy model.
Map it wo subclasses, put the 2 one-to-many into the same super class.

The proper way is to modify your db schema.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.