-->
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.  [ 1 post ] 
Author Message
 Post subject: Multiple one-to-one associations
PostPosted: Wed Jul 29, 2009 7:29 am 
Newbie

Joined: Tue May 05, 2009 4:51 pm
Posts: 3
Hi All,
Last time I am trying to solve one problem.
So:
I have one table "body", which is associate to two hands. Left hand, and right hand.
I tried to do it by using <one-to-one> associaton.
Classes are looks like:
Code:
class Hand
{
    Long handId;
    //Other attributes, getters and setters
}

class Body
{
     Long bodyId;
     Hand leftHand;
     Hand rightHand;
     //Other attributes, getters and setters
}


DB schema is looks like:
Code:
TABLE BODY,
"BODY_ID" NUMBER(19,0) NOT NULL ENABLE,
"LEFT_HAND_ID" NUMBER(19,0) NOT NULL DISABLE,
"RIGHT_HAND_ID" NUMBER(19,0) NOT NULL DISABLE,
PRIMARY KEY "BODY_ID";

TABLE HAND,
"HAND_ID" NUMBER(19,0) NOT NULL ENABLE,
PRIMARY KEY(HAND_ID);


In hbm's I'm using sequence generators to each id.
Now everything is working on <many-to-one> associations, but I want to use <one-to-one>.
Is there any possibilities to use <one-to-one> ?
How can I do it?

p.s.That example is simple representation of my problem in big application.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.