-->
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: one-to-one associations in Hibernate
PostPosted: Tue Mar 24, 2009 8:40 pm 
Newbie

Joined: Mon Mar 23, 2009 1:42 pm
Posts: 2
Is it possible to declare in Hibernate a perfect one-to-one association between a shared primary key, this is, all the values in a PK column need to be exactly the same in another PK column.

Generally, a one-to-one mapping defines a foreign key such as in the book, p. 279), but it just enforces that the ADDRESS_ID values appear in the USER_ID column, but not the other way around.

This is quite an hard problem in the relational database, because it implies cyclic foreign keys such as in http://sqlserver-tips.blogspot.com/2006 ... nship.html, what I presume not to be a standard solution.

I wonder if Hibernate could handle this property since it is hard to express in the database itself. This, of course, would require to insert the corresponding user when inserting a new address and vice-versa, and the application would enforce it to happen.

Many thanks,
hugo


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