-->
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: @OnetoOne + Lazy loading with optional=false
PostPosted: Wed Sep 26, 2007 6:44 pm 
Beginner
Beginner

Joined: Fri Oct 06, 2006 2:49 am
Posts: 25
Hi everybody,

I have a currently a bidirectional relation one-to-one. I want lazy loading for my one-to-one relation

See under the example:
Code:
class A {
@OneToOne(fetch=FetchType.LAZY, cascade=Cascade.ALL, mappedBy="a")
B b;
}


class B {
@OneToOne(fetch=FetchType.LAZY, optional="false")
A a;
}


I do not want in my case to load the object A when I am loading an object B.

In my understanding of Hibernate, the relation cannot be lazy loaded if the object A contained in B can be null. When we specify optional=false, it means that we ensure that we cannot have null value and Hibernate is therefore able to create a proxy for A when it is loading B.

Can somebody tell where I am wrong because this solution is not working for me ?

Thanks in advance,
Tiggy


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.