我有一个非常简单的类,它给出了一个奇怪的错误。它非常简单,与另一个表没有任何关系。最奇怪的部分似乎是随机发生的,尤其是当我的网站有大量请求时...我使用的是版本2.0.1.400的Nhibernate。
我在网上搜索过它,大多数有同样问题的人说这是Nhibernate在论坛上的一个大错...以前有人遇到过这类问题吗?并附带解决方案?
这可能是数据库连接的问题,汇集了什么???
关于它的最疯狂的事情,有时只发生,所以网站瘫痪..在IIS重置后,一切正常,但后来谁知道什么时候会再次发生!
我得到了:
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>
实体和映射类似乎都很好,否则我的网站会一直失败......它偶尔会失败......
有什么想法吗?
答案 0 :(得分:0)
确保仅在没有其他会话处于活动状态时才实例化新的休眠会话。这将使会话竞争相同的资源并导致像条件一样的死锁。如果有这样的事情,只需删除第二个会话并使用第一个会话本身来查询数据库。