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 collection can't be retrieved due to 2 opened readers
PostPosted: Tue Jun 03, 2008 10:35 am 
Beginner
Beginner

Joined: Thu Apr 27, 2006 5:49 am
Posts: 31
Hibernate version:
1.2.0GA

While analyzing log files I found a couple of exception messages that says that NHibernate couldn't lazily load collections. What is interesting that the internal exception says: There is already an open DataReader associated with this Command which must be closed first.

Here is the full stack trace.

Code:
     <StackTrace>   
   at NHibernate.Loader.Loader.LoadCollection(ISessionImplementor session, Object id, IType type)
   at NHibernate.Loader.Collection.CollectionLoader.Initialize(Object id, ISessionImplementor session)
   at NHibernate.Persister.Collection.AbstractCollectionPersister.Initialize(Object key, ISessionImplementor session)
   at NHibernate.Impl.SessionImpl.InitializeCollection(IPersistentCollection collection, Boolean writing)
   at NHibernate.Collection.AbstractPersistentCollection.Initialize(Boolean writing)</StackTrace>
    <InnerException>
      <ExceptionType>System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
      <Message>There is already an open DataReader associated with this Command which must be closed first.</Message>
      <Source>System.Data</Source>
      <HelpLink />
      <Property name="Data">System.Collections.ListDictionaryInternal</Property>
      <Property name="TargetSite">Void ValidateConnectionForExecute(System.Data.SqlClient.SqlCommand)</Property>
      <StackTrace>   at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
   at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)
   at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
   at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
   at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
   at NHibernate.Loader.Loader.LoadCollection(ISessionImplementor session, Object id, IType type)</StackTrace>


I've checked the forum and find out that it was already discussed here. The difference between the previous post and my is that I don't use a separate query, instead I can't load lazy collection.

I've checked the code and I am sure there is no asynchronous calls to session. I also store my session in HttpContext.Items so it is single for one web request.

So the question is: is there anything else I should check?


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.