-->
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.  [ 5 posts ] 
Author Message
 Post subject: One-to-one constrained=true in annotations
PostPosted: Thu May 24, 2007 3:12 pm 
Newbie

Joined: Thu May 24, 2007 3:00 pm
Posts: 2
I had the problem posted here:

http://forum.hibernate.org/viewtopic.php?t=974246
(excessive fetching, even when using HQL)

Which led me to the solution posted here:

http://www.hibernate.org/162.html
(specify constrained relations on one-to-one mappings)

I want to try the solution mentioned, which is along the lines of...

<one-to-one constrained="true" outer-join="false" class="Foo"/>

...but I am using annotations and cannot find the annotations equivalent of the XML node above (specifically, the "constrained" part). I've Googled this and not found anything; the big Manning book doesn't say much about it, either. I peeked at the Annotations API but quickly got lost. Can anyone tell me, how do I specify a one-to-one constrained relationship in Hibernate Annotations?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 3:09 pm 
Newbie

Joined: Thu May 24, 2007 3:00 pm
Posts: 2
::ping::

anyone have an answer on this? even a simple "rtmf!" would be nice, if youve got a link or page number...


Top
 Profile  
 
 Post subject: Re: One-to-one constrained=true in annotations
PostPosted: Mon Sep 14, 2009 2:19 am 
Newbie

Joined: Sun Sep 13, 2009 3:48 pm
Posts: 2
no answer yet? I'm facing the same problem?

regards
Meex


Top
 Profile  
 
 Post subject: Re: One-to-one constrained=true in annotations
PostPosted: Mon Sep 14, 2009 5:11 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
Hi, constrained="true" is use in case of shared primary key. (in case of parent child relationship, when child's primary key works as foreign key pointing to primary key of parent)..

Equivalent annotation is

@PrimaryKeyJoinColumn

(for more information look at chapter 7 of "Java Persistence with Hibernate").


Top
 Profile  
 
 Post subject: Re: One-to-one constrained=true in annotations
PostPosted: Wed May 25, 2011 11:35 am 
Newbie

Joined: Wed May 25, 2011 11:27 am
Posts: 1
I know this is a bit late, but we found that setting optional=false on the @OneToOne annotation did what you're looking for, einnocent.

It's the opposite of constrained="true" from HBM, in that this association is required, such that null can never be returned for the association and a proxy is used for lazy loading.


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