-->
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: one-to-one with just unique keys
PostPosted: Wed Jan 21, 2004 9:38 am 
Newbie

Joined: Wed Jan 14, 2004 3:56 pm
Posts: 7
Location: Ann Arbor, MI, USA
I have a one-to-one relationship, but the relation is defined by unique keys rather than primary keys. The DB tables are:
Code:
create table CG_USER
(
  USER_ID   NUMBER not null, (primary key, Hibernate generated)
  ORACLE_ID VARCHAR2(30) not null (unique)
)
create table EMPLOYEE (read only, not under my control)
(
  EMPLID    VARCHAR2(30) not null, (primary key)
  UNIQUE_ID VARCHAR2(30) not null  (unique)
)

The classes are:
CgUser - id, oracleId, employee
Employee - emplid, uniqueId

The one-to-one relation is defined by ORACLE_ID and UNIQUE_ID. The Employee property of CgUser may be null.

Can this relation be mapped by Hibernate? If not, any suggestions as to how best to handle it? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 10:03 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at the property-ref attribute

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 12:30 pm 
Newbie

Joined: Wed Jan 14, 2004 3:56 pm
Posts: 7
Location: Ann Arbor, MI, USA
property-ref: The name of a property of the associated class that is joined to the primary key of this class.

I'm not sure how that helps, since it still involves a primary key.

I can see how to do this if I get rid of the synthetic key, USER_ID, and simply use the ORACLE_ID field as the PK. But then I'm using something that has a domain meaning as a key. I prefer not to do that in tables that I control.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 12:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I read too fast.
I don't think you can. Do a plain HQL query for that.

_________________
Emmanuel


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.