-->
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.  [ 1 post ] 
Author Message
 Post subject: Bag update for inherited entities question
PostPosted: Wed May 03, 2006 10:12 am 
Newbie

Joined: Wed May 03, 2006 9:49 am
Posts: 4
NHibernate version: 1.0.2
SQLServer 2005

Hello,

I have a Products table that uses a discriminator column (IsSpecialOffer) to distinguish between Product entities and SpecialOffer entities that contain a set of child products.

The SpecialOffer Class inherites from the Product Class and adds a Product collection property;

Here is the mapping file:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="HdSites.IProduct, HD-ES" table="Products">
   
    <id name="ID" column="ProductID" type="int">
      <generator class="native" />
    </id>
    <discriminator column="IsSpecialOffer"/>
   
    <property name="Name"></property>
    <property name="CategoryID"></property>
    <property name="Description"></property>
    <property name="Price"></property>
    <property name="ShippingPrice"></property>
    <property name="ImgName" column ="ImageName"></property>
    <property name="ProductType"></property>
    <property name="IsShippable"></property>
    <property name="IsActive"></property>
    <property name="IsNewProduct"></property>


    <subclass name="HdSites.Product, HD-ES" discriminator-value="False">
     
      <property name="ResourceName"></property>
      <property name="AdditionaRequiredlInfo"></property>
      <property name="IsDownload"></property>
    </subclass>

    <subclass name="HdSites.SpecialOffer, HD-ES" discriminator-value="True">
      <bag name="Products" table="SpecialOffersProducts">
        <key column="SpecialOfferID" />
        <many-to-many column="ProductID" class="HdSites.Product, HD-ES" />
      </bag>
    </subclass>
   

  </class>
</hibernate-mapping


There three tables invloved:

1. The Products table (that carries all of product/offer data and has ProductID as PrimaryKey)

2. the SpecialOffers table (that has a Name and SpecialOfferID (PK) columns)

3. the SpecialOfferProducts table that has two Columns (SpecialOfferID and ProductID) both of which are clustered as a PrimaryKey.

It all works very well except that when i update the Products property/bag of a SpecialOffer object the SpecialOfferProducts table (in effect the link) is not modified.

Also if i delete a specialOffer object the SpecialOfferProducts table is not modified.

I have searched through the documentaion but have not found a solution.

Can any one offer some insight?

thank you.


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

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.