-->
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: Many-To-Many Mapping for a Map
PostPosted: Wed Dec 29, 2004 3:53 pm 
Newbie

Joined: Fri Mar 19, 2004 3:53 pm
Posts: 6
Hibernate version:
2.1.6

Mapping documents:

The location side:
<map
name="groups"
table="location_group"
lazy="false"
sort="natural"
inverse="false"
cascade="save-update"
>

<key
column = "location_id"
>
</key>

<index
column="group_id"
type="long"
/>

<many-to-many
class="com.example.model.Group"
column="group_id"
outer-join="auto"
/>
</map>

The Group side:

<map
name="locations"
table="location_group"
lazy="false"
sort="unsorted"
inverse="true"
cascade="save-update"
>

<key column="group_id"></key>

<index column="location_id" type="long"/>

<many-to-many
class="com.example.model.Location"
column="location_id"
outer-join="auto"
/>
</map>

Background Information:
Many locations can have many groups.
The primary key of the app_location table is "location_id" and the primary key of the app_group table is "group_id".

What I want to do:
I want to set up a many-to-many relationship between the two classes Location and Group. Location has a Map named "groups". Group has a Map named "locations".
When I retrieve a location object by its "location_id" I want all of the "groups" to be loaded into the "groups" Map and have the group objects stored in the HashMap by their unique "group_id". Thus, allowing me to remove an individual group from the groups Map by calling on groups.remove(group.getGroupId()); and then calling on the Hibernate save method.
Hopefully this makes sense. I am a newbie... so I think that my example mapping is probably full of errors. I have been using the Hibernate in Action book to map this out... but have not been able to determine what I need to do for a mapping of type Map. I think I need to specify an "element" in this mapping.

Thanks in advance!
Christopher


Top
 Profile  
 
 Post subject: did you find any solution ?
PostPosted: Mon Feb 21, 2005 11:27 am 
Beginner
Beginner

Joined: Thu Jun 17, 2004 10:08 am
Posts: 21
Location: Paris-France
Hi,
I have the same problem; did you find any solution ?

thank's

Ady


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.