-->
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: How do I map one to many throught intermediate table?
PostPosted: Wed Sep 01, 2004 9:51 am 
Newbie

Joined: Tue Apr 13, 2004 6:41 am
Posts: 19
public class Person {
Long id;
String name;
List addresses;
}

public class Address {
Long id;
String street;
Person person;
}

Legacy DB Schema:

Table: person

id
name


Table: person_addresses

person_id
address_id (unique)

Table: address
id
street

For MANY end I can do:

<bag name="addresses" table="person_addresses">
<key column="person_id"/>
<many-to-many class="Address" column="address_id"/>
</bag>

How can I map "person" attribute???


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 1:05 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
map it as a many to many, on the "one" side your collection will always have only one element... you can just add a business method that get this element

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.