从NHibernate 3.1.0.4升级到4.0.4.4时遇到IndexOutOfRangeException。
包含参数的HQL命名查询在输入NHibernate.Hql.Ast.ANTLR.Tree.FromElement clas的RenderText()方法时导致IndexOutOfRangeException。下面的HQL查询:
<query name="NameQuery">
<![CDATA[
select od.id, od.Assigned.Number
from od
where od.Status = :status
and od.Assigned.Number in (:number)
]]>
</query>
NHibernate代码保留了一系列参数。在尝试引用第一个索引时,会发现该数组为空并且抛出了IndexOutOfRangeException。下面是堆栈跟踪的输出:
**System.IndexOutOfRangeException**: Index was outside the bounds of the array.
at NHibernate.Hql.Ast.ANTLR.Tree.FromElement.RenderText(ISessionFactoryImplementor sessionFactory) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\Tree\FromElement.cs:line 347
at NHibernate.Hql.Ast.ANTLR.SqlGenerator.Out(IASTNode n) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\SqlGenerator.cs:line 137
at NHibernate.Hql.Ast.ANTLR.SqlGenerator.NestedFromFragment(IASTNode d, IASTNode parent) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\SqlGenerator.cs:line 260
at NHibernate.Hql.Ast.ANTLR.SqlGenerator.tableJoin(IASTNode parent) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\Generated\SqlGenerator.cs:line 3492
at NHibernate.Hql.Ast.ANTLR.SqlGenerator.fromTable() in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\Generated\SqlGenerator.cs:line 3260
at NHibernate.Hql.Ast.ANTLR.SqlGenerator.from() in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\Generated\SqlGenerator.cs:line 3137
at NHibernate.Hql.Ast.ANTLR.SqlGenerator.selectStatement() in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\Generated\SqlGenerator.cs:line 376
at NHibernate.Hql.Ast.ANTLR.SqlGenerator.statement() in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\Generated\SqlGenerator.cs:line 274
at NHibernate.Hql.Ast.ANTLR.HqlSqlGenerator.Generate() in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs:line 609
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs:line 351
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2 replacements, Boolean shallow) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs:line 70
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs:line 39
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs:line 24
at NHibernate.Engine.Query.QueryExpressionPlan.CreateTranslators(IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Engine\Query\QueryExpressionPlan.cs:line 32
at NHibernate.Engine.Query.QueryExpressionPlan..ctor(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Engine\Query\QueryExpressionPlan.cs:line 13
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters) in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Engine\Query\QueryPlanCache.cs:line 67
at NHibernate.Impl.SessionFactoryImpl.CheckNamedQueries() in c:\Users\x\Downloads\nhibernate-core-4.0.x\src\NHibernate\Impl\SessionFactoryImpl.cs:line 1157
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) in c:\Users\x\Downloads
我没有成功识别导致此参数Array为空的原因。有什么建议吗?