I know it's simple for you guys but I can't make it work!
I have three tables in the database: Products, ProductsPriceGroups and PriceGroups.
One product can have different prices depending on which pricegroup the customer is in.
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Swh.Entities.Product, Swh.Entities" table="Products">
<id name="Id" column="ProductId" type="int" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" column="ProductName" type="String"/>
<bag name="Prices" table="ProductsPriceGroups" lazy="true">
<key column="ProductId"/>
<property name="Price" column="Price" type="double"/>
<many-to-one column="PriceGroupId" class="Swh.Entities.PriceGroup, Swh.Entities" />
</bag>
</hibernate-mapping>
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Swh.Entities.Pricegroup, Swh.Entities" table="PriceGroups">
<id name="Id" column="PriceGroupId" type="int" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" column="PriceGroupName" type="String"/>
</class>
</hibernate-mapping>
The problem with this code is that
bag doesn't allow a
property.
So, how should the mapping look like?
(I have looked at the product/order/orderline example but I can't translate it to my problem!)