Hi all,
I've a problem mapping my objects. Let's imagine you have a product class and a category class.
Product class has a Category property and category class has a Product
So when I check Product.Category property I have the category linked to the product or Null value if no category is linked.
When I check the Category.Product property, I have the product linked to that category.
My example is quite bad because a category should contain many products but it's not what i want, i want a one-to-one relation.
If I delete a product, all is ok.
But when I want to delete a category, I have an error. I would like to make NHibernate delete the category from its table and to set Ref_IdCategory value to null for the product concerned by this deleted category.
Here is my mapping :
Product :
Code:
<class="product">
<many-to-one name="Category" column="Ref_IdCategory" class="Category" />
</class>
Category :
Code:
<class="Category">
<one-to-one name="Product" foreign-key="Ref_IdCategory" class="Product" />
</class>
Do you have an idea about the mistake I made ?
Thanks
BR