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.