-->
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.  [ 4 posts ] 
Author Message
 Post subject: How do I map one-to-one with foreign key???
PostPosted: Tue Aug 31, 2004 8:22 am 
Newbie

Joined: Tue Apr 13, 2004 6:41 am
Posts: 19
public class Person () {
Long id;
String name;
Account account;
}

public Account() {
Long id;
String number;
Person person;
}

LEGACY DB:

TABLE PERSON

ID
NAME

TABLE ACCOUNT

ID
NUMBER
PERSON_ID

How can I map these classes to given DB schema??

I can use <many-to-one/> to map person in Account. But how do I map account in Person???

Rihards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 31, 2004 8:31 am 
Newbie

Joined: Tue Apr 13, 2004 6:41 am
Posts: 19
And the Answer is:

<class name="Person">

</class>

<class name="Account">
...
<many-to-one name="person" class="Account" column="person_id">
</class>

<class name="Person">
...
<one-to-one name="account" class="Person" property-ref="person">
</class>


?????


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 30, 2004 10:55 am 
Newbie

Joined: Tue Apr 13, 2004 6:41 am
Posts: 19
one of ends should have inverse="true"


Top
 Profile  
 
 Post subject: legacy java
PostPosted: Mon Oct 25, 2004 6:34 pm 
Beginner
Beginner

Joined: Tue Oct 07, 2003 4:32 pm
Posts: 36
Location: S
I


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