-->
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: Status of 'OneToOne and Lazy Loading' problem
PostPosted: Tue Aug 28, 2007 7:12 am 
Newbie

Joined: Thu Aug 02, 2007 5:44 am
Posts: 8
Location: Belgium
Hi,

in http://forum.hibernate.org/viewtopic.php?t=958455, it is said that it is possible to use lazy loading for one-to-one mapping by turning 'optional' flag to false.

However, it does not seem to work for me, and there is a comment in http://www.hibernate.org/162.html stating that it is not possible to use it with JPA.

What is the status? Is it possible?

Note that I annotate attributes and not getters. I guess I should annotate the getter to allow Hibernate to intercept call and check the other side of the relationship exists. Shouldn't I?

Also, I don't understand why Hibernate loads the whole object on the other side of relationships, and not just check that there is 'something'.

Just checking would already help us.

Cheers,

J-F


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 4:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
AFAIK the wiki comment is wrong.

@OneToOne(optional=false) should to the trick

And field or getter use are irrelevant, both will work.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 2:41 am 
Newbie

Joined: Thu Aug 02, 2007 5:44 am
Posts: 8
Location: Belgium
It does not work for us. I can still see the SQL statement retrieving the whole counterpart object.

I could mention that it is the 'weak' part (i.e. 'mappedBy') of a bidirectional association. Maybe it is related.

I would also appreciate if someone could shed some light on why Hibernate does not just check that the counterpart object exists, instead of loading it.

This is a real problem for us, because the counterpart object itself has eager relationships.

Cheers,

J-F


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 30, 2007 5:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ah year mappedBy need to load the object since the FK is "on the other table".
The rational is that since a DB access is needed, it is preferable to load the object.

On a related note, EAGER in the mapping is usually not a good idea.

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