-->
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: Subclass association mappings- multiple subclasses
PostPosted: Sun Aug 20, 2006 4:26 pm 
Newbie

Joined: Sun Aug 20, 2006 4:05 pm
Posts: 1
I'm using table-per-class-hierarchy inheritance for an entity called, Promotion. One subclass, PriceDiscount, has a bi-directional many-to-one association to VendorContract (see below). Is there a way to specify a Java interface in the "class" element of the one-to-many mapping in VendorContract (see IDealBuyPromotion in VendorContract mapping)? I will need to add an additional subclasses that map to a VendorContract.

Hibernate version:
3.1
Mapping documents:
in Promotion.hbm.xml...
<subclass name="PriceDiscount" discriminator-value="pricing">
<property name="pricingRulePriority" type="string" length="6"/>
<many-to-one name="vendorContract" column="vendorContractID" class="VendorContract" />
</subclass>

in VendorContract.hbm.xml...
<!-- one-to-many mapping for DealBuy Promotion implementors. -->
<bag name="dealBuyPromotions" cascade="save-update" lazy="true" inverse="true">
<key>
<column name="vendorContractID" />
</key>
<one-to-many class="IDealBuyPromotion"/>
</bag>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 20, 2006 5:56 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
No, but you can add a where="" attribute to the bag, duplicating the effect of the descriminator. Something like:
Code:
<bag name="dealBuyPromotions" cascade="save-update" lazy="true" inverse="true" where="promoType='pricing'">
  <key>
    <column name="vendorContractID" />
  </key>
  <one-to-many class="VendorContractImpl"/>
</bag>
I'm assuming that the descriminator column on the Promotion table is called promoType.

_________________
Code tags are your friend. Know them and use them.


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.