-->
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: Mapping association table with data and index column as key
PostPosted: Sat Sep 08, 2007 2:08 am 
Newbie

Joined: Sat Sep 08, 2007 1:49 am
Posts: 1
Hi,

I'm in desperate need of help with creating the right mapping for the following scenario:

users table: pk=userid, password, etc...
addresses table: pk=addressid, street, etc.
useraddresses table: pk=(userid, position), addressid, description

Notes:
1. Each user can have multiple addresses (1:N) but every address is associated with only one user.
2. I'm mostly interested in unidirectional navigation: user->address
3. I'd like to use either user.getAddresses() or if that doesn't work - user.getUserAddresses().get(0).getAddress()
4. I'd like Hibernate to advance the position column automatically (a la the list-index concept) and to automatically assign the userid and addressid values to the appropriate columns in the useraddresses table and then insert the record.

I tried so many mapping approaches and couldn't get it right. Can anyone tell me if this is doable and if it is - what kind of mapping I should use?

Many thanks in advance!
Alan


Hibernate version: 3.x


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.