-->
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: Bag update for inherited entities question
PostPosted: Wed May 03, 2006 10:07 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.

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.[/list]

It all works very well except that when i update the Products 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  
 
 Post subject:
PostPosted: Wed May 03, 2006 7:00 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
There is no reference to a SpecialOffers table anywhere in your mapping. Is that correct?

The class name in the bag's many-to-many does not match the name in the class mapping. I'm guessing that the name in the class mapping is wrong? Is HdSites.IProduct an interface? If it is, it's not appropriate for a mapping (unless that's something that NHibernate offers.. I don't use NHibernate).

_________________
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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.