-->
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: Hibernate.initialize with session per request
PostPosted: Fri Feb 10, 2006 5:43 pm 
Beginner
Beginner

Joined: Tue Feb 17, 2004 11:20 am
Posts: 28
Hi,

I have a question about the Hibernate.initialize functionality.

I have struts application with Filter creating and closing the session for each request with the ThreadLocal pattern.

I have a object which has 2 lazy collections and 5 proxied properties.

session1 opens
I found 5 of this MAIN object in the db using criteria query.
session1 closes as view jsp has been rendered.

user click which object wants to edit
session2 opens
I reattach the object to the current session
session.lock(object, LockMode.NONE);

here I would like to initialize some of the properties which are proxies of the object calling the
Hibernate.initialize(object.getProperty1());
session2 closes

session3 opens
I want to access the object.getProperty1 and I got an LazyInitialization exception....

I'm little bit confused about this. this is a sentence from HIA ->

Hibernate.initialize(cat) will
force the initialization of a proxy, cat, as long as its Session is still open.

of course the session of the proxied property1 object is not open anymore.

but I CAN NOT call the initialize in the session1 where the object was loaded as I have a collection of them there and that would not make any sense.


is there an other way to force a proxy object to get initialized???

would this make any sense? >

session2.lock(object.getProperty1(), LockMode.NONE);
Hibernate.initialize(object.getProperty1());

or this would not work either?

am I doing something wrong here? (quiet likely :))

THanks for any help!

Istvan


Hibernate version:
3.1.2


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.