I am trying to use a map for a many to many relationship. I have a Customer table, a CustomerOffer bridge table, and an Offer table. The CustomerOffer table has CustomerID and OfferID as a composite primary key.
I have successfully mapped this using a bag, but I want to use a map instead. I want to be able to access a customer offer by customer.Offer[offerID]. In other words, the index is the offerID. OfferID must be unique to a customer.
However, when I try to switch the bag to a map, I start to get errors. Here is what I think I need to do.
Code:
<map generic="true" name="Offers" inverse="false" lazy="false" cascade="all-delete-orphan" table="CustomerOffer">
<key column="CustomerID"></key>
<index type="int" column="OfferID"/>
<many-to-many class="SMSMarketing.BLL.Offer,SMSMarketing.BLL" column="OfferID"/>
</map>
However, this give a "OfferID already mapped" error. If I remove the OfferID from the <many-to-many> tag, then I get a bad load error, the generated SQL doesn't get the left-hand OfferID in the join.
What is the correct way of doing this, or is it possible?
D.