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.  [ 2 posts ] 
Author Message
 Post subject: IndexOutOfange exception while loading proxy object
PostPosted: Mon Aug 11, 2008 11:26 am 
Beginner
Beginner

Joined: Thu Apr 27, 2006 5:49 am
Posts: 31
Hi guys,

I have a problem I've encountered today. It is about loading object via session.Load(). As you all know that session.Load() creates a proxy object if it can and it does so in my case. Then if you call a property or a method it will first load the entity and then executes the property/method.

There are some cases when calling to property of the proxied-entity generates an IndexOutOfRangeException. The exception message states that it couldn't find the column in the query results. It happens rarely in an unpredictable way.

Well, the problem is that I have such a column in sql excerpt. Here is the stack trace:

Code:

at System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName)
   at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name)
   at NHibernate.Driver.NHybridDataReader.GetOrdinal(String name)
   at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
   at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
   at NHibernate.Loader.Loader.GetKeyFromResultSet(Int32 i, ILoadable persister, Object id, IDataReader rs, ISessionImplementor session)
   at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies)
   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.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Type optionalEntityName, Object optionalIdentifier, IEntityPersister persister)
   at NHibernate.Loader.Entity.AbstractEntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId)
   at NHibernate.Loader.Entity.AbstractEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session)
   at NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted)
   at NHibernate.Impl.SessionImpl.ImmediateLoad(Type clazz, Object id)
   at NHibernate.Proxy.LazyInitializer.Initialize()
   at NHibernate.Proxy.CastleLazyInitializer.Intercept(IInvocation invocation, Object[] args)


NHibernate version I use is 1.2.1.4000 and it is used on MS SQL 2005.

I've checked the forum, but there seems nothing like my problem. Has anyone encountered this before? Maybe I should rewrite the code so it will use session.Get instead of session.Load?


Top
 Profile  
 
 Post subject: See this thread
PostPosted: Fri Aug 29, 2008 11:57 am 
Newbie

Joined: Fri Feb 22, 2008 9:34 pm
Posts: 2
Look here: http://forum.hibernate.org/viewtopic.ph ... getordinal

it looks like it's a problem with the underlying datareader. One person has a demonstrable fix for it. I don't know if the fix is in 2.0, though.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.