-->
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.  [ 6 posts ] 
Author Message
 Post subject: anyway around it?
PostPosted: Fri May 26, 2006 5:08 pm 
Newbie

Joined: Thu May 18, 2006 11:30 pm
Posts: 9
I have a User table and an Address table. One User should only have one Address. So, ideally, User table should contain an FK column for Address and many-to-one will get me the correct object relationships.

However, the tables are not done this way. Rather, a separate table User_Address was created. What kind of mapping can get me the relationship of one User containing one Address? Changing the table is not an option.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 7:30 pm 
Beginner
Beginner

Joined: Thu Aug 19, 2004 2:33 pm
Posts: 30
Location: CA, USA
Hibernate has a one-to-one mapping you can define. You can define from your User table to the Address table. Have you tried that?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 8:54 pm 
Newbie

Joined: Thu May 18, 2006 11:30 pm
Posts: 9
The trouble I'm having is how to get the link table into the picture for either many-to-one or one-to-one.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 27, 2006 1:03 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 2:33 pm
Posts: 30
Location: CA, USA
Can you post the tables and columns? it's not clear to me what they are.

It sounds like you have three tables: User > User_Address > Address

So you have a join table even though there only ever one address per user.

I think you're stuck having to create three java beans, one for each table and using either the one-to-one mapping or one-to-many.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 27, 2006 5:09 am 
Beginner
Beginner

Joined: Tue Oct 18, 2005 3:57 pm
Posts: 48
Location: Los Angeles, CA
tong wrote:
The trouble I'm having is how to get the link table into the picture for either many-to-one or one-to-one.

Have you read the reference doc?

http://www.hibernate.org/hib_docs/v3/reference/en/html/associations.html#assoc-unidirectional-join


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 27, 2006 8:58 am 
Newbie

Joined: Thu May 18, 2006 11:30 pm
Posts: 9
I did the In Action book and did some google search, but should really have RTDM.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.