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: Lazy Load error while load new page
PostPosted: Mon Jun 08, 2009 2:21 am 
Newbie

Joined: Sat Jan 13, 2007 1:43 am
Posts: 5
Hi all,
Today I try using NHibernate 1.2.0 and Castle, but meed this error: NHibernate.LazyInitializationException] - "Failed to lazily initialize a collection - no session"

I have to table Student and Class, an FK make relation Class with Student is 1 - N. I need to count number of student in one class. I use a page called classlist.aspx to show all class. It appears if I change to new page, all class and its number of student in page 1 is view ok.

I read and know function NHibernate.NHibernateUtil.IsInitialized() but it still was wrong if i use objClass.Students.Count to count student.

To make it work, I change value of property lazy like bellow:
Code:
<bag name="SchoolClasses" inverse="true" lazy="false" cascade="all-delete-orphan">xxx</bag>


But I think it is not good, it reduces performance of my web application.

Anyone was wrong on this? Would you have any suggestion please?
Thank u very much!


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.