-->
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.  [ 3 posts ] 
Author Message
 Post subject: Not lazy collection consisting of lazy objetcs
PostPosted: Fri Apr 06, 2007 6:18 am 
Newbie

Joined: Wed May 31, 2006 12:58 pm
Posts: 14
Hello everybody, I use Hibernate 2 and I'd have the following question:

In a class mapping I declare a bag-collection which is not indicated to be a lazy one (so, this is a parent object). This collection contains objects of a class, who has a "proxy" attribute in its mapping (and these are child-objects). The colection may also be empty.

When I get a parent object with an HQL query (in which I write nothing about that collection), I get a LazyInitializationException when I try to access the collection's elements later (that is right and it is clear, why it happens - a "proxy" attribute). So, I should specify in my query that all elements of the collection are to initialize when I am fetching the parent object. How can I do it? Should a "LEFT JOIN FETCH" construction work? Seems like JOIN FETCH does not work...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 06, 2007 8:13 am 
Newbie

Joined: Fri Apr 06, 2007 8:01 am
Posts: 2
it is easy to do this:
use before you make query.lis(); you must specify the fetch mode of your object if you use it as proxy in the mapping file
like criteria.SetFetchMode("object.object", FetchMode.Join); or
criteria.SetFetchMode("object.object", FetchMode.select);

_________________
ahmed ali
Developer at ISFP company


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 06, 2007 8:50 am 
Newbie

Joined: Wed May 31, 2006 12:58 pm
Posts: 14
And if I do not use Criteria?


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