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
|