-->
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: Using a map for a many-to-many association
PostPosted: Wed Jan 10, 2007 5:20 pm 
Newbie

Joined: Wed Jan 10, 2007 5:11 pm
Posts: 1
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.


Top
 Profile  
 
 Post subject: Re: Using a map for a many-to-many association
PostPosted: Sun Jan 14, 2007 8:39 am 
Newbie

Joined: Sun Jan 14, 2007 8:36 am
Posts: 3
Mekon wrote:
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.


Hi there, I'm trying to do the same thing with a map , but I'm keep getting the error : "Error mapping generic collection Techno_Fly.ContactCenter.Core.List.List_ListItems: expected 2 generic parameters, but the property type has 1"

How does your class look like ?? is there any good documentation already available about this ?? where ? can't seem to find it

grtz!


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