-->
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.  [ 1 post ] 
Author Message
 Post subject: Modelling issue with ternary relation
PostPosted: Tue Jul 06, 2004 12:36 pm 
Newbie

Joined: Tue Jul 06, 2004 12:06 pm
Posts: 1
Hi,

I've been wrestling with a modelling issue for a couple of days and could really use some insight / tips from others. Here's the situation:

I've got three entities in an online game: Club, Player and Round. A Player can play for a Club in one or more Rounds. The tables look like this:

TABLE player:
- id INTEGER(10) unsigned PRIMARY KEY
- name VARCHAR(25)
- etc.. (no foreign keys)

TABLE club
- id INTEGER(10) unsigned PRIMARY KEY
- name VARCHAR(25)
- etc.. (no foreign keys)

TABLE round
- id INTEGER(10) unsigned PRIMARY KEY
- number INTEGER(10) unsigned
- etc.. (no foreign keys)

TABLE clubmembership
- clubid (foreign key to the club table)
- playerid (foreign key to the player table)
- roundid (foreign key to the club table)
- (clubid, playerid, roundid) PRIMARY KEY
- some other attributes (no more foreign keys)

Now, what I'd like to do is use code like this:

List players = club.getPlayers(round3);

Therefore I figure I need to set up a map in the club mapping, something like this:

<map name="players" table="clubmembership">
<key column="clubid"/>
<index-many-to-many class="Round" column="roundid"/>
???
</map>

But I can't figure out how to get a List (or Set) of players for each round. I've read in the documentation that it's actually not possible to set up a map that returns a collection of values for a key.

Is there another approach to achieve the desired results, without changing the database tables (legacy data, changes to the datamodel should be avoided if possible)?

Any tips / insights would be greatly appreciated.

(using hibernate2)


Thanks, Michael


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.