c# – NHibernate – NHibernate.Exceptions.GenericADOException:无法执行查询

c# – NHibernate – NHibernate.Exceptions.GenericADOException:无法执行查询,第1张

概述我似乎随机发生以下异常: NHibernate.Exceptions.GenericADOException: could not execute query [ select businesspr0_.BusinessProcessID as col_0_0_, businesspr0_.ProcessNumber as col_1_0_, businesspr1_.Name as co 我似乎随机发生以下异常:

NHibernate.Exceptions.GenericADOException: Could not execute query    [ select businesspr0_.BusinessProcessID as col_0_0_,businesspr0_.ProcessNumber as col_1_0_,businesspr1_.name as col_2_0_,businesspr0_.DateCreated as col_3_0_,actor2_.displayname as col_4_0_,usergroup3_.name as col_5_0_,processele5_.name as col_6_0_ from BusinessProcess businesspr0_ inner join BusinessProcess businesspr1_ on businesspr0_.DeFinitionID=businesspr1_.BusinessProcessID inner join Actor actor2_ on businesspr0_.ActorCreatedID=actor2_.ActorID left outer join UserGroup usergroup3_ on businesspr0_.UserGroupCreatedID=usergroup3_.UserGroupID left outer join Actor usergroup3_1_ on usergroup3_.UserGroupID=usergroup3_1_.ActorID inner join ActiveElement activeelem4_ on businesspr0_.BusinessProcessID=activeelem4_.BusinessProcessID inner join ProcessElement processele5_ on activeelem4_.ProcessElementID=processele5_.ProcessElementID inner join ProcessEmployees processemp6_ on businesspr0_.BusinessProcessID=processemp6_.BusinessProcessID inner join Actor actor7_ on processemp6_.ActorID=actor7_.ActorID inner join UserInGroups users8_ on actor7_.ActorID=users8_.UserGroupID inner join AppUser user9_ on users8_.UserID=user9_.UserID inner join Actor user9_1_ on user9_.UserID=user9_1_.ActorID where businesspr0_.IsDeFinition=0 and (businesspr0_.Finished is null) and @p0=user9_.UserID ]      name:userID - Value:32771    [sql: select businesspr0_.BusinessProcessID as col_0_0_,processele5_.name as col_6_0_ from BusinessProcess businesspr0_ inner join BusinessProcess businesspr1_ on businesspr0_.DeFinitionID=businesspr1_.BusinessProcessID inner join Actor actor2_ on businesspr0_.ActorCreatedID=actor2_.ActorID left outer join UserGroup usergroup3_ on businesspr0_.UserGroupCreatedID=usergroup3_.UserGroupID left outer join Actor usergroup3_1_ on usergroup3_.UserGroupID=usergroup3_1_.ActorID inner join ActiveElement activeelem4_ on businesspr0_.BusinessProcessID=activeelem4_.BusinessProcessID inner join ProcessElement processele5_ on activeelem4_.ProcessElementID=processele5_.ProcessElementID inner join ProcessEmployees processemp6_ on businesspr0_.BusinessProcessID=processemp6_.BusinessProcessID inner join Actor actor7_ on processemp6_.ActorID=actor7_.ActorID inner join UserInGroups users8_ on actor7_.ActorID=users8_.UserGroupID inner join AppUser user9_ on users8_.UserID=user9_.UserID inner join Actor user9_1_ on user9_.UserID=user9_1_.ActorID where businesspr0_.IsDeFinition=0 and (businesspr0_.Finished is null) and @p0=user9_.UserID] ---> system.indexOutOfRangeException: col_0_0_       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.Hql.Ast.ANTLR.Loader.queryLoader.GetResultColumnorRow(Object[] row,IResulttransformer resulttransformer,IDataReader rs,ISessionImplementor session)       at NHibernate.Loader.Loader.GetRowFromresultSet(IDataReader resultSet,queryParameters queryParameters,LockMode[] lockModeArray,EntityKey optionalObjectKey,IList hydratedobjects,EntityKey[] keys,Boolean returnProxIEs)       at NHibernate.Loader.Loader.Doquery(ISessionImplementor session,Boolean returnProxIEs)       at NHibernate.Loader.Loader.DoqueryAndInitialiZenonLazyCollections(ISessionImplementor session,Boolean returnProxIEs)       at NHibernate.Loader.Loader.DoList(ISessionImplementor session,queryParameters queryParameters)       --- End of inner exception stack trace ---       at DotExe.TiCat.DomainModel.Repository.ProcessModel.BusinessProcessDAO.GetProcessForUserGroups(Int32 userID) in D:\Projects\TiCatRNIDS\DotExe.TiCat4\DotExe.TiCat.DomainModel.Repository\ProcessModel\BusinessProcessDAO.cs:line 98       at DotExe.TiCat4.UseCaseRepository.TicketProcess.TicketQueues.RefreshQueue() in D:\Projects\TiCatRNIDS\DotExe.TiCat4\DotExe.TiCat4\UseCaseRepository\TicketProcess\TicketQueues.cs:line 128

奇怪的部分是这个system.indexOutOfRangeException:col_0_0_我无法弄清楚为什么会发生.
如有必要,我可以使用一些xml映射更新帖子.

TNX

更新:

映射和查询抛出ex:

<?xml version="1.0" enCoding="utf-8" ?><hibernate-mapPing xmlns="urn:nhibernate-mapPing-2.2" assembly="DotExe.TiCat.DomainModel" namespace="DotExe.TiCat.DomainModel.Process">  <class name="BusinessProcess" table="BusinessProcess">    <ID name="BusinessProcessID">      <generator />    </ID>    <property name = "name" length="1024" type="string" not-null ="false" />    <property name = "Description" length="5000" type="string" not-null ="false" />    <property name = "ProcessNumber" length="500" type="string" not-null ="false" />    <property name = "CommentOnSolve" length="5000" type="string" not-null ="false" />    <property name="IsDeFinition" type="bool"/>    <property name="PlaningTimetoSpend" type="long"/>    <property name="SpendTime" type="long"/>    <property name="DateCreated" type="DateTime" not-null="false"/>    <property name="PlanToStart" type="DateTime" not-null="false"/>    <property name="PlanToFinish" type="DateTime" not-null="false"/>    <property name="Started" type="DateTime" not-null="false"/>    <property name="Finished" type="DateTime" not-null="false"/>    <property name="CustomerRequestCallBack" type="bool" not-null="false"/>    <property name="EscalationTimelimitInPercents" type="int"/>    <property name="IsEscalated" type="bool"/>    <property name="IsInfinite" type="bool"/>    <many-to-one name="WorkingWeek"  column="WorkingWeekID" not-null="false" lazy="false"/>    <many-to-one name="Priority"  column="PriorityID" not-null="false" lazy="false"/>    <many-to-one name="UserCreated"  column="ActorCreatedID" not-null="false" lazy="false"/>    <many-to-one name="UserSolved"  column="ActorSolvedID" not-null="false" lazy="false"/>    <many-to-one name="GroupCreated"  column="UserGroupCreatedID" not-null="false" lazy="false"/>    <many-to-one name="GroupSolved"  column="UserGroupSolvedID" not-null="false" lazy="false"/>    <many-to-one name="DeFinition"  column="DeFinitionID" cascade="none" />          <set name="Elements" lazy="false" cascade="save-update">      <key column="BusinessProcessID"/>      <one-to-many />    </set>    <set name="ActiveElements" table="ActiveElement" lazy="false" cascade="save-update">      <key column="BusinessProcessID"/>      <many-to-many  column="ProcessElementID"/>    </set>    <set name="ProcessConsumers" table="ProcessConsumers" lazy="false" cascade="save-update">      <key column="BusinessProcessID"/>      <many-to-many  column="ActorID"/>    </set>    <set name="ProcessEmployees" table="ProcessEmployees" lazy="false">      <key column="BusinessProcessID"/>      <many-to-many  column="ActorID"/>    </set>    <set name="ProcessSupervisors" table="ProcessSupervisors" lazy="false">      <key column="BusinessProcessID"/>      <many-to-many  column="ActorID"/>    </set>    <set name="Flows" lazy="false" cascade="save-update">      <key column="BusinessProcessID"/>      <one-to-many />    </set>    <set name="PriorityTimeRules" lazy="false" cascade="save-update">      <key column="BusinessProcessID"/>      <one-to-many />    </set>  </class>  <class name="ProcessElement" table="ProcessElement">    <ID name="ProcessElementID">      <generator />    </ID>    <property name = "name" length="1024" type="string" not-null ="true" />    <property name="IsDeFinition" type="bool"/>    <property name="Isstate" type="bool"/>    <many-to-one  name="MemberOf" lazy="false" cascade="save-update" column="BusinessProcessID"/>    <many-to-one  name="DeFinition" column="DeFinitionID"/>    <joined-subclass name="Activity">      <key column="ActivityID"/>      <property name = "name" length="1024" type="string" not-null ="true" />      <property name = "Description" length="4000" type="string" not-null ="false" />      <set name="States" >        <key column="ActivityID"/>        <one-to-many />      </set>      <joined-subclass name="UserTask" table="UserTask">        <key column="UserTaskID"/>        <property name="PlaningTimetoSpend" type="int"/>        <property name="SpendTime" type="int"/>        <property name="PlanToStart" type="DateTime" not-null="false"/>        <property name="PlanToFinish" type="DateTime" not-null="false"/>        <property name="Started" type="DateTime" not-null="false"/>        <property name="Finished" type="DateTime" not-null="false"/>        <set name="Comments">          <key column="UserTaskID"/>          <one-to-many />        </set>        <set name="UserTaskEmployees">          <key column="UserTaskID"/>          <many-to-many  column="ActorID"/>        </set>        <set name="UserTaskSupervisors">          <key column="UserTaskID"/>          <many-to-many  column="ActorID"/>        </set>        <set name="PrioritIEs">          <key column="UserTaskID"/>          <one-to-many />        </set>        <set name="AssignmentRules">          <key column="UserTaskID"/>          <one-to-many />        </set>        <many-to-one  name="Application" column="ApplicationConfigID"/>        <many-to-one  name="TaskPriority" column="TaskPriorityID"/>      </joined-subclass>      <joined-subclass name="SendTask">        <key column="SendTaskID"></key>        <many-to-one name="EmailAccount"  column="EmailAccountID" lazy="false"></many-to-one>        <many-to-one name="Template"  column="TemplateID" lazy="false"></many-to-one>        <set name="Actors" lazy="false">          <key column="SendTaskID"></key>          <many-to-many  column="ActorID"></many-to-many>        </set>        <set name="EmailMessages">          <key column="SendTaskID"></key>          <one-to-many />        </set>      </joined-subclass>    </joined-subclass>    <joined-subclass name="Gateway">      <key column="GatewayID"/>      <joined-subclass name="ExclusiveGateway">        <key column="ExclusiveGatewayID"/>      </joined-subclass>    </joined-subclass>    <joined-subclass name="Event">      <key column="EventID"></key>      <property name="ExecutionTime" type="DateTime" not-null="false"></property>      <joined-subclass name="StartEvent">        <key column="StartEventID"></key>      </joined-subclass>      <joined-subclass name="EndEvent">        <key column="EntEventID"></key>      </joined-subclass>    </joined-subclass>  </class>  <class name="ActivityState" table="ActivityState">    <ID name="ActivityStateID">      <generator />    </ID>    <property name = "name" length="1024" type="string" not-null ="true" />    <property name = "Description" length="4000" type="string" not-null ="false" />    <many-to-one name="StateOf"  column="ActivityID"/>    <property name="IsEndState" type="bool"/>    <property name="IsstartState" type="bool"/>    <property name="IsPauseState" type="bool"/>    <property name="IsProcessSerializationState" type="bool"/>  </class>  <class name="SequenceFlow" table ="SequenceFlow">    <ID name="SequenceFlowID">      <generator />    </ID>    <many-to-one  name="Source" column="SourceID" lazy="false" cascade="save-update"/>    <many-to-one  name="Target" column="TargetID" lazy="false" cascade="save-update"/>    <many-to-one name="Process"  column="BusinessProcessID" cascade="save-update"/>  </class>  <class name="UserTaskPriority" table ="UserTaskPriority">    <ID name="UserTaskPriorityID">      <generator />    </ID>    <property name = "name" length="1024" type="string" not-null ="true" />  </class>  <class name="TaskComment" table ="TaskComment">    <ID name="TaskCommentID">      <generator />    </ID>    <property name = "Comment" length="4000" type="string" not-null ="true" />    <many-to-one name="Task"  column="UserTaskID"/>    <many-to-one name="Actor"  column="ActorID"/>    <many-to-one name="Process"  column="BusinessProcessID"/>    <many-to-one name="Group"  column="UserGroupID"/>    <property name="CommentTime" type="DateTime" not-null="false" />  </class>  <class name="TransitionLog">    <ID name="TransitionLogID">      <generator />    </ID>    <property name="LogDate" type="DateTime"/>    <property name="TaskStarted" type="DateTime" not-null ="false" />    <property name="TaskEnded" type="DateTime" not-null ="false" />    <property name="TimeSpend" type="int" not-null ="false" />    <set name="SendToActors" table="SendToActorLog" lazy="false">      <key column="TransitionLogID"/>      <many-to-many  column="ActorID"/>    </set>    <many-to-one name="Actor"  column="ActorID" lazy="false"/>    <many-to-one name="Group"  column="UserGroupID"/>    <many-to-one name="fromElement"  column="fromElementID" lazy="false"/>    <many-to-one name="toElement"  column="toElementID"/>    <many-to-one name="Process"  column="BusinessProcessID"/>    <many-to-one name="LogType"  column="LogTypeID" lazy="false"/>    <property name="Comment" length="4000" type="string" not-null ="false" />  </class>  <class name="LogType">    <ID name="LogTypeID"/>    <property name = "name" length="1024" type="string" not-null ="false" />    <property name = "displayname" length="1024" type="string" not-null ="false" />  </class>  <class name="Processpriority">    <ID name="ProcesspriorityID"/>    <property name = "name" length="1024" type="string" not-null ="false" />    <property name = "displayname" length="1024" type="string" not-null ="false" />  </class>  <class name="WorkingWeek">    <ID name="WorkingWeekID">      <generator />    </ID>    <property name="MondayFrom" type="DateTime" not-null="true"/>    <property name="MondayTo" type="DateTime" not-null="true"/>    <property name="TuesdayFrom" type="DateTime" not-null="true"/>    <property name="TuesdayTo" type="DateTime" not-null="true"/>    <property name="WednesdayFrom" type="DateTime" not-null="true"/>    <property name="WednesdayTo" type="DateTime" not-null="true"/>    <property name="ThursdayFrom" type="DateTime" not-null="true"/>    <property name="ThursdayTo" type="DateTime" not-null="true"/>    <property name="FrIDayFrom" type="DateTime" not-null="true"/>    <property name="FrIDayTo" type="DateTime" not-null="true"/>    <property name="SaturdayFrom" type="DateTime" not-null="true"/>    <property name="SaturdayTo" type="DateTime" not-null="true"/>    <property name="SundayFrom" type="DateTime" not-null="true"/>    <property name="SundayTo" type="DateTime" not-null="true"/>    <property name="Is24x7" type="bool"/>    <property name="name" type="string" length="256" not-null="true"/>    <!--<set name="BusinessProcesses" cascade="none" lazy="false">      <key column="WorkingWeekID"/>      <one-to-many />    </set>-->  </class></hibernate-mapPing>

和查询:

IList<object[]> result =                        session.createquery(" select bp.BusinessProcessID,bp.ProcessNumber,def.name as DeFinition," +                                            " bp.DateCreated,actor.displayname as UserCreated," +                                            " group.name as GroupCreated,task.name as ActiveTask " +                                            " from BusinessProcess bp " +                                            " join bp.DeFinition as def " +                                            " join bp.UserCreated as actor " +                                            " left join bp.GroupCreated as group " +                                            " join bp.ActiveElements as task" +                                            " join bp.ProcessEmployees as res" +                                            " join res.Users as users " +                                            " where bp.IsDeFinition = false " +                                            " and bp.Finished is null" +                                            " and :userID = users.ActorID").SetParameter("userID",userID).List<object[]>();
解决方法 当我尝试将空值映射到不可为空的属性(即整数)时,我遇到了这个错误.确保你确保sql值是不可为空的,或者只是使c#属性为nullable(public virtual int?NumberOfPoints {get; set;}) 总结

以上是内存溢出为你收集整理的c# – NHibernate – NHibernate.Exceptions.GenericADOException:无法执行查询全部内容,希望文章能够帮你解决c# – NHibernate – NHibernate.Exceptions.GenericADOException:无法执行查询所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1228562.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存