-->
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.  [ 7 posts ] 
Author Message
 Post subject: One-to-One Relationship
PostPosted: Tue Aug 30, 2005 12:14 am 
Newbie

Joined: Mon Aug 29, 2005 12:53 am
Posts: 13
I have two table.

Person
- personId
- name
- contactId

Contact
- contactId
- address

One person only maps to one contact. How to use xdoclet to explain it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 12:32 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
What? Your going to have to elaborate a little here.


Top
 Profile  
 
 Post subject: check this out
PostPosted: Tue Aug 30, 2005 12:38 am 
Newbie

Joined: Wed Aug 03, 2005 1:08 am
Posts: 8
Location: aa
Person table mapping

<one-to-one name="contact"
class="Contact"
cascade="all" >


Contact table mapping

<id name="conatctId" column="conatctId" type="integer">
<generator class="foreign">
<param name="property">person</param>
</generator>
</id>

<one-to-one name="person" class="Person" constrained="true" cascade="all"/>


this technique is called Primary Key association where one table's pk is mapped as foreign key to other table's pk.

try it.

_________________
aaa


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 12:39 am 
Newbie

Joined: Mon Aug 29, 2005 12:53 am
Posts: 13
dennisbyrne wrote:
What? Your going to have to elaborate a little here.


I have two tables. The relationship between them is one to one. I go to read the hibernate reference. But, I can not find how to use xdoclet to generate the map files.

Class Preson{
/**
* @hibernate.one-to-one constrained="true"
*/
public Contact getContact() {
return contact;
}
}
Class Contact {
...
}

But, the result is the contact ID of Contact refer to the contact ID of the Person.


Top
 Profile  
 
 Post subject: check this out
PostPosted: Tue Aug 30, 2005 12:40 am 
Newbie

Joined: Wed Aug 03, 2005 1:08 am
Posts: 8
Location: aa
Person table mapping

<one-to-one name="contact"
class="Contact"
cascade="all" >


Contact table mapping

<id name="conatctId" column="conatctId" type="integer">
<generator class="foreign">
<param name="property">person</param>
</generator>
</id>

<one-to-one name="person" class="Person" constrained="true" cascade="all"/>


this technique is called Primary Key association where one table's pk is mapped as foreign key to other table's pk.

try it.

_________________
aaa


Top
 Profile  
 
 Post subject: Re: check this out
PostPosted: Tue Aug 30, 2005 12:45 am 
Newbie

Joined: Mon Aug 29, 2005 12:53 am
Posts: 13
itandon wrote:
Person table mapping

<one-to-one name="contact"
class="Contact"
cascade="all" >


Contact table mapping

<id name="conatctId" column="conatctId" type="integer">
<generator class="foreign">
<param name="property">person</param>
</generator>
</id>

<one-to-one name="person" class="Person" constrained="true" cascade="all"/>


this technique is called Primary Key association where one table's pk is mapped as foreign key to other table's pk.

try it.


Yes, I know it.
I want to use the xdoclet to generate the mapping file. On the other hand, they have different primary key.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 1:27 am 
Newbie

Joined: Mon Aug 29, 2005 12:53 am
Posts: 13
Thx~ finally, I generate the mapping file. But, the primary key of person refers to the primary key of the contact. The right result should be the contact id of the person refers to the contact id of Contact.


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