获取'无法执行查询#39;首次尝试使用NHibernate对Oracle执行查询

时间:2015-04-13 10:08:54

标签: c# oracle nhibernate fluent-nhibernate

我正在研究的系统背景:

这是一个拥有大约500个表的Oracle数据库的企业系统,目前我们在NHibernate中映射了大约400个表。

我们正在运行Oracle 11。

代码是用.Net 3.5上的C#编写的。

我们正在使用NHibernate版本:3.3.1.4000。

现在问题:

在authurization逻辑期间,我们首先设置NHibernate SessionFactory,这需要大约1分钟,之后我们第一次调用数据库,这就是我得到错误:

could not execute query
[ select USERID353_,OBJVERSION353_,FIRSTNAME353_,LASTNAME353_,DEPARTMENT353_,USERINIT6_353_,INTERNAL7_353_,MEMODIST8_353_,EMAILADD9_353_,USERCOM10_353_,DELETED353_,ADDRESS353_,DEFAULT13_353_ from ( select sprintuser0_.USERID as USERID353_, sprintuser0_.OBJVERSION as OBJVERSION353_, sprintuser0_.FIRSTNAME as FIRSTNAME353_, sprintuser0_.LASTNAME as LASTNAME353_, sprintuser0_.DEPARTMENT as DEPARTMENT353_, sprintuser0_.USERINITIALS as USERINIT6_353_, sprintuser0_.INTERNALADDRESS as INTERNAL7_353_, sprintuser0_.MEMODISTRIBUTIONGROUP as MEMODIST8_353_, sprintuser0_.EMAILADDRESS as EMAILADD9_353_, sprintuser0_.USERCOMMENT as USERCOM10_353_, sprintuser0_.DELETED as DELETED353_, sprintuser0_.ADDRESS as ADDRESS353_, sprintuser0_.DEFAULTRESPONSIBILITYAREAOID as DEFAULT13_353_ from SPRINTUSER sprintuser0_ where sprintuser0_.USERID=:p0 ) where rownum <=1 ]
  Name:p1 - Value:V0C0359
[SQL: select USERID353_,OBJVERSION353_,FIRSTNAME353_,LASTNAME353_,DEPARTMENT353_,USERINIT6_353_,INTERNAL7_353_,MEMODIST8_353_,EMAILADD9_353_,USERCOM10_353_,DELETED353_,ADDRESS353_,DEFAULT13_353_ from ( select sprintuser0_.USERID as USERID353_, sprintuser0_.OBJVERSION as OBJVERSION353_, sprintuser0_.FIRSTNAME as FIRSTNAME353_, sprintuser0_.LASTNAME as LASTNAME353_, sprintuser0_.DEPARTMENT as DEPARTMENT353_, sprintuser0_.USERINITIALS as USERINIT6_353_, sprintuser0_.INTERNALADDRESS as INTERNAL7_353_, sprintuser0_.MEMODISTRIBUTIONGROUP as MEMODIST8_353_, sprintuser0_.EMAILADDRESS as EMAILADD9_353_, sprintuser0_.USERCOMMENT as USERCOM10_353_, sprintuser0_.DELETED as DELETED353_, sprintuser0_.ADDRESS as ADDRESS353_, sprintuser0_.DEFAULTRESPONSIBILITYAREAOID as DEFAULT13_353_ from SPRINTUSER sprintuser0_ where sprintuser0_.USERID=:p0 ) where rownum <=1]
   at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes)
   at NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
   at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results)
   at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters)
   at NHibernate.Impl.ExpressionQueryImpl.List()
   at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery)
   at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
   at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
   at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
   at t916DataRepository.t916Common.SprintUserRespository.GetSprintUserEagerly(String userId) in c:\Builds\30\14\Sources\Server\t916DataRepository\t916Common\SprintUserRespository.cs:line 17
   at t916Common.com.common.authorization.AuthorizationMgr2.GetUserDataStructure(String userId)
   at t916CommonService.Services.AuthorizationService.GetUserDataStructure2(String userId) in c:\Builds\30\14\Sources\Server\t916CommonService\Services\AuthorizationService.svc.cs:line 726
NHibernate
ORA-00028: your session has been killed
   at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
   at Oracle.DataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
   at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session)
   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)
Oracle Data Provider for .NET

如果我在大约一秒钟后尝试相同的操作,那就可以了。

此错误只会偶尔发生。

1 个答案:

答案 0 :(得分:1)

内部异常会告诉你原因。

添加:通常,在处理.Net代码时,您必须始终以递归方式记录或查看所有内部异常。