NHibernate.ADOException:无法执行查询 - > System.IndexOutOfRangeException:id13_ [英] NHibernate.ADOException: could not execute query --> System.IndexOutOfRangeException: id13_

查看:181
本文介绍了NHibernate.ADOException:无法执行查询 - > System.IndexOutOfRangeException:id13_的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的类,给出一个奇怪的错误。这是一个很简单的一个,并与另一个表没有关系。最奇怪的部分是,似乎发生随机,但特别是当我的网站有大量的请求负载...我使用Nhibernate是2.0.1.400版本。

I've got a really simple class that is giving a strange error. It's quite simple one and has no relationship with another table. The strangest part is that seems to happen randomly but especially when my website had heavy load of requests... I use Nhibernate that is version 2.0.1.400.

我有一个关于它的搜索和大多数有相同的问题说,这是一个高度的Nhibernate在论坛上的错误...任何人都有这种问题之前?并提供了解决方案?

I had a search on net about it and most of them who had same problem say that is highly a bug of Nhibernate on forums... Anyone had have this kind of problem before? and came with a solution?

这可能是数据库连接的问题,pooling stuff ???

Could this be a problem with the database connection, pooling stuff ???

关于它的最疯狂的事情,只发生有时,所以网站下来..后IIS重置,一切工作正常,但然后谁知道什么时候会再次发生!

The craziest thing about it, only occurs sometimes and so the website goes down.. after IIS reset, all works fine, but then who knows when it's gonna occur again!

我得到:

Server Error in '/' Application.

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: Unipa Belediye Master Select<T>(string p_sql,bool closeSession) de Sorun Var ---> NHibernate.ADOException: could not execute query
[ select gelirgenel0_.id as id13_, gelirgenel0_.ParametreAdi as Parametr2_13_, gelirgenel0_.KullanimNedeni as Kullanim3_13_, gelirgenel0_.Degeri as Degeri13_ from Parametre.GelirGenelParametre gelirgenel0_ where (id in(6 , 7 , 62 , 65)) ]
[SQL: select gelirgenel0_.id as id13_, gelirgenel0_.ParametreAdi as Parametr2_13_, gelirgenel0_.KullanimNedeni as Kullanim3_13_, gelirgenel0_.Degeri as Degeri13_ from Parametre.GelirGenelParametre gelirgenel0_ where (id in(6 , 7 , 62 , 65))] ---> System.IndexOutOfRangeException: id13_
  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.DoList(ISessionImplementor session, QueryParameters queryParameters)
  --- End of inner exception stack trace ---
  at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
  at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes)
  at NHibernate.Hql.Classic.QueryTranslator.List(ISessionImplementor session, QueryParameters queryParameters)
  at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
  at NHibernate.Impl.SessionImpl.List(String query, QueryParameters queryParameters, IList results)
  at NHibernate.Impl.SessionImpl.List[T](String query, QueryParameters parameters)
  at NHibernate.Impl.QueryImpl.List[T]()
  at UnipaBelediyeMaster.Master.Select[T](String p_sql, Boolean closeSession) in D:\BelediyeNet\Web\Menu.Src\UnipaBelediyeMaster\UnipaBelediyeMasterr\Master.cs:line 449
  --- End of inner exception stack trace ---
  at UnipaBelediyeMaster.Master.Select[T](String p_sql, Boolean closeSession) in D:\BelediyeNet\Web\Menu.Src\UnipaBelediyeMaster\UnipaBelediyeMasterr\Master.cs:line 461
  at Service.GelirGenelParametreAlIdler(String idler) in c:\webServiceBornovaBel\App_Code\Service.cs:line 1044
  --- End of inner exception stack trace ---

下面是我的实体类:

[Serializable]
    public class GelirGenelParametre
    {
        #region Member Variables
        protected decimal _id;
        protected string _parametreadi;
        protected string _kullanimnedeni;
        protected string _degeri;
        #endregion
        #region Constructors

        public GelirGenelParametre() {}

        public GelirGenelParametre(decimal id, string parametreadi, string kullanimnedeni, string degeri) 
        {
            this._id= id;
            this._parametreadi= parametreadi;
            this._kullanimnedeni= kullanimnedeni;
            this._degeri= degeri;
        }

        #endregion
        #region Public Properties
        public  virtual decimal Id
        {
            get { return _id; }
            set {_id= value; }
        }
        public  virtual string ParametreAdi
        {
            get { return _parametreadi; }
            set {_parametreadi= value; }
        }
        public  virtual string KullanimNedeni
        {
            get { return _kullanimnedeni; }
            set {_kullanimnedeni= value; }
        }
        public  virtual string Degeri
        {
            get { return _degeri; }
            set {_degeri= value; }
        }
        #endregion

并映射xml:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <!--Build: with lujan99@usa.net Nhibernate template-->
  <class name="UnipaBelediyeMaster.GelirGenelParametre,UnipaBelediyeMaster" table="GelirGenelParametre" lazy="false" schema="Parametre">
    <id name="Id" column="id" type="Decimal">
      <generator class="assigned" />
    </id>
    <property name="ParametreAdi" column="ParametreAdi" type="string" not-null="true" />
    <property name="KullanimNedeni" column="KullanimNedeni" type="string" not-null="true" />
    <property name="Degeri" column="Degeri" type="string" not-null="true" />
  </class>
</hibernate-mapping>

实体和映射类似乎很好,否则我的网站会一直失败...只是失败了每一次,然后...

Both entity and mapping classes seems fine, otherwise my website would be failed all the time... it just fails every now and then...

任何想法?

推荐答案

确保您只在没有其他会话活动时才实例化一个新的hibernate会话。这将使会话竞争相同的资源,并导致类似条件的死锁。如果有这样的东西,只需删除第二个会话,并使用第一个会话本身来查询数据库。

Make sure that you are instantiating a new hibernate session only when there is no other session active. This would make the sessions compete for the same resource and result in deadlock like condition. If there is something like this, simply remove the second session and use the first session itself to query the database.

这篇关于NHibernate.ADOException:无法执行查询 - &gt; System.IndexOutOfRangeException:id13_的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆