注册

NHibernate-3.0.0.GA版本调用SetMaxResults出错

欢乐马 2022/03/01 931 1

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:8
【操作系统】:windows Server 2008 R2
【CPU】:
【问题描述】*:
使用NHibernate-3.0.0.GA访问数据库。
查询全表的数据时,可以正常读取。
当使用SetMaxResults限制读取数据的最大条数时,程序报错

query.SetFirstResult(startSum).SetMaxResults(endSum).List<T>()

错误信息如下:

  StackTrace:
       在 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
       在 NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
       在 NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes)
       在 NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters)
       在 NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters)
       在 NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
       在 NHibernate.Impl.SessionImpl.List(String query, QueryParameters queryParameters, IList results)
       在 NHibernate.Impl.SessionImpl.List[T](String query, QueryParameters parameters)
       在 NHibernate.Impl.QueryImpl.List[T]()
       在 Model.Repository.StandardRepository`1.GetTopSumObjectByOrder(Int32 startSum, Int32 endSum, String whereString, String orderProp, Boolean isDesc) 位置 C:\jyjt\jyjtSystem-DM\Model\Repository\StandardRepository.cs:行号 201
       在 Platform.BLL.UserManager.FindUnitsByMatchString(String matchString, String currentUnitNO, Nullable`1 searchAll) 位置 C:\jyjt\jyjtSystem-DM\Platform\BLL\UserManager.cs:行号 185
       在 _dynamic_Platform.BLL.UserManager.FindUnitsByMatchString(Object , Object[] )
       在 Spring.Reflection.Dynamic.SafeMethod.Invoke(Object target, Object[] arguments)
       在 Spring.Aop.Framework.DynamicMethodInvocation.InvokeJoinpoint()
       在 Spring.Aop.Framework.AbstractMethodInvocation.Proceed()
       在 Spring.Transaction.Interceptor.TransactionInterceptor.Invoke(IMethodInvocation invocation)
  InnerException: System.NotSupportedException
       Message=Override to support limits passed as parameters
       Source=NHibernate
       StackTrace:
            在 NHibernate.Dialect.Dialect.GetLimitString(SqlString querySqlString, Int32 offset, Int32 limit, Nullable`1 offsetParameterIndex, Nullable`1 limitParameterIndex)
            在 NHibernate.Loader.Loader.PrepareQueryCommand(QueryParameters queryParameters, Boolean scroll, ISessionImplementor session)
            在 NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
            在 NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
            在 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
回答 0
暂无回答
扫一扫
联系客服