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.  [ 3 posts ] 
Author Message
 Post subject: noobie question
PostPosted: Thu Dec 01, 2005 6:39 am 
Newbie

Joined: Thu Dec 01, 2005 6:32 am
Posts: 5
Hy, guys!!I am starting with Hibernate , and have a noobie question.I get it that if I want to use a foreign key where the column is also the primary key of the table, I use a code like this:

<id name="id" type="long" column="CONTACT" >
<generator class="foreign" >
<param name="property">Contact</param>
</generator>
</id>

<one-to-one name="Contact" class="roseindia.tutorial.hibernate.Contact" />

but How should I do it when the foreign column is not the primary key column ??for example:

<id name="id" type="long" column="ID" >
<generator class="increment" />
</id>

//here I want to declare property , and one of them is also a foreign key

<one-to-one name="Contact" class="roseindia.tutorial.hibernate.Contact" />


how I do it??Thanks for the help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 8:52 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
You can look at:

http://forum.hibernate.org/viewtopic.php?t=950749&highlight=

You can also look:
http://caveatemptor.hibernate.org

This is a good implementation of all features of hibernate.


Top
 Profile  
 
 Post subject: Use many-to-one
PostPosted: Thu Dec 01, 2005 9:01 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Have a look in the reference docs, section 6.1.11 "One-to-one". The last bit describes what you want: many-to-one unique="true".


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