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: Lazy Initialization of a Collection - Current 1.2 Code
PostPosted: Wed Aug 30, 2006 10:06 am 
Newbie

Joined: Fri May 13, 2005 11:14 am
Posts: 18
I'm getting the dreaded "Could not initialize proxy - the owning Session was closed." message when trying to access a property of an object in a collection that was Lazy-Loaded. What do I need to do?

Here are the details:

I have an ASP.NET website. I go and retrieve an object out of the database (which has a lazy loaded collection). I then call the Collection.GetEnumerator() (which before in 1.0.2 would cause the collection to completely load). Then I close the session. I then loop through the collection and retrieve each object and access its properties. That is when I get the error message. Is there another way to intialize a collection completely now?

I have changed all the properties and methods of classes that are lazy-loaded to virtual.

Thanks,
Jamie


Top
 Profile  
 
 Post subject: Re: Lazy Initialization of a Collection - Current 1.2 Code
PostPosted: Wed Aug 30, 2006 11:40 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
jdcaram wrote:
I'm getting the dreaded "Could not initialize proxy - the owning Session was closed." message when trying to access a property of an object in a collection that was Lazy-Loaded. What do I need to do?

Here are the details:

I have an ASP.NET website. I go and retrieve an object out of the database (which has a lazy loaded collection). I then call the Collection.GetEnumerator() (which before in 1.0.2 would cause the collection to completely load). Then I close the session. I then loop through the collection and retrieve each object and access its properties. That is when I get the error message. Is there another way to intialize a collection completely now?

I have changed all the properties and methods of classes that are lazy-loaded to virtual.


The elements of collection - are they lazy loaded? I mean, the 1.2 did change default value of lazy from "false" to "true". So, if the classes are not soecifically marked as lazy="false", the collection might be loaded, but the elements will still remain uninistialized.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 30, 2006 12:07 pm 
Newbie

Joined: Fri May 13, 2005 11:14 am
Posts: 18
Correct. Once I changed all my mapping files to have default-lazy to false (below), then Properties (like name) came in.

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-lazy="false">

Thank you,
Jamie


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.