Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate System.IndexOutOfRangeException
    text
    copied!<p>I've got a really simple class that is giving a strange error. The class only has 1 property and the query is really simple. The stranglest part is that this seems to happen randomly. After getting this error usually refreshing the page makes it go a way and the application doesn't get the errror again.</p> <p>Could this be a problem with the database connection?</p> <p>I'm getting:</p> <pre><code>[IndexOutOfRangeException: Department5_] System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +4839010 System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +67 NHibernate.Driver.NHybridDataReader.GetOrdinal(String name) +46 NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name) +87 NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner) +62 NHibernate.Loader.Loader.GetKeyFromResultSet(Int32 i, IEntityPersister persister, Object id, IDataReader rs, ISessionImplementor session) +213 NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies) +301 NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +1422 NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +114 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +205 [ADOException: could not execute query [ select department0_.Department as Department5_ from tblDepartments department0_ where department0_.Department like 'CBS - %' ] [SQL: select department0_.Department as Department5_ from tblDepartments department0_ where department0_.Department like 'CBS - %']] NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +383 NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +52 NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) +183 NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) +102 NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) +684 NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) +816 NHibernate.Impl.SessionImpl.List(String query, QueryParameters queryParameters, IList results) +277 NHibernate.Impl.SessionImpl.List(String query, QueryParameters parameters) +235 NHibernate.Impl.QueryImpl.List() +224 DispatchBoard.Models.Repository.Find(String hql) +76 DispatchBoard.Controllers.HomeController.Filter() +48 lambda_method(ExecutionScope , ControllerBase , Object[] ) +39 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24 System.Web.Mvc.&lt;&gt;c__DisplayClassa.&lt;InvokeActionMethodWithFilters&gt;b__7() +52 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254 System.Web.Mvc.&lt;&gt;c__DisplayClassc.&lt;InvokeActionMethodWithFilters&gt;b__9() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +192 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +399 System.Web.Mvc.Controller.ExecuteCore() +126 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +27 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +151 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57 System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75 </code></pre> <p>Here is my class</p> <pre><code>public class Department : IObject { public virtual string Name { get; set; } } </code></pre> <p>The hbm file</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt; &lt;class name="DispatchBoard.Models.Department, DispatchBoard" table="tblDepartments"&gt; &lt;id name="Name" column="Department" type="String" length="50"&gt; &lt;generator class="assigned" /&gt; &lt;/id&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>and here is the HQL query</p> <pre><code>var hql = "from Department d where d.Name like 'CBS - %'"; _session.CreateQuery(hql).List&lt;T&gt;(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload