-->
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: Forcing the lazily mapped association to load.
PostPosted: Thu Dec 11, 2008 12:32 pm 
Newbie

Joined: Thu Mar 15, 2007 7:43 am
Posts: 8
Hi All,

I use Hibernate3 along with Spring 2.5 and JSF1.2.

I need a way to load all association in my DAO where connection is available.
Either by calling Hibernate api method or by some other means.

Use case.
User logs in and sees different groups. (These groups are lazily loaded and required so)
After clicking on one group, he sees the group members. As I am in GUI layer I do not have connection available and do not want to use Spring support for starting connection in GUI layer. (Group and member are lazily mapped) So I call my DAO again by passing Group object and expect this DAO to load all members into it non-lazily.

How can I do that?

TIA and Best Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2008 2:40 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
org.hibernate.Hibernate.initialize()

It takes a uninitialized proxy or collection as a parameter. It must of course be connected to an open session.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2008 6:01 pm 
Newbie

Joined: Thu Mar 15, 2007 7:43 am
Posts: 8
Thanks for the answer.

Unfortunately Hibernate.initialise method only works on proxy objects it does not load the collections.

Is there any other way?

-Prasad


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2008 6:08 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Oh... but the documentation says:

Quote:
Force initialization of a proxy or persistent collection
.

I have never had any use for it, but I have always assumed that it should work if I needed to... Could it be a Hibernate bug?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 14, 2008 9:21 am 
Newbie

Joined: Thu Mar 15, 2007 7:43 am
Posts: 8
It works using Hibernate.initialize() method. If you pass entire collection as a parameter to the initialize method.


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.