我遇到Hql Query的问题:
FROM PhysikalischesObjekt physikalischesObjekt LEFT OUTER JOIN FETCH physikalischesobjekt.AktuelleInstallation installation
如你所见 - 我正在使用名称与实体相似的别名(在第一个位置只有较低的字母)。
如果我对Nhibernate执行此查询,我会收到InvalidPathException:
NHibernate.Hql.Ast.ANTLR.InvalidPathException : Invalid path: 'physikalischesobjekt.AktuelleInstallation' [FROM PhysikalischesObjekt physikalischesObjekt LEFT OUTER JOIN FETCH physikalischesobjekt.AktuelleInstallation installation ]
堆栈跟踪:
> NHibernate.dll!NHibernate.Hql.Ast.ANTLR.Util.LiteralProcessor.LookupConstant(NHibernate.Hql.Ast.ANTLR.Tree.DotNode node) Zeile 81 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.Tree.DotNode.Resolve(bool generateJoin, bool implicitJoin, string classAlias, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode parent) Zeile 208 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.Tree.FromReferenceNode.Resolve(bool generateJoin, bool implicitJoin, string classAlias) Zeile 58 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.CreateFromJoinElement(NHibernate.Hql.Ast.ANTLR.Tree.IASTNode path, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode alias, int joinType, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode fetchNode, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode propertyFetch, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode with) Zeile 681 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.joinElement() Zeile 3955 + 0x3c Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromElement() Zeile 3617 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromElementList() Zeile 3391 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromClause() Zeile 3308 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() Zeile 1645 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() Zeile 1510 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() Zeile 536 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() Zeile 435 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() Zeile 590 + 0x1b Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(string collectionRole) Zeile 449 + 0x12 Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(System.Collections.Generic.IDictionary<string,string> replacements, bool shallow, string collectionRole) Zeile 354 + 0x13 Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(System.Collections.Generic.IDictionary<string,string> replacements, bool shallow) Zeile 72 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(NHibernate.Hql.Ast.ANTLR.Tree.IASTNode ast, string queryIdentifier, string collectionRole, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> filters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 43 + 0xa3 Bytes Unknown
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(string queryString, string collectionRole, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> filters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 21 + 0x3a Bytes C#
NHibernate.dll!NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(string hql, string collectionRole, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> enabledFilters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 24 + 0x99 Bytes C#
NHibernate.dll!NHibernate.Engine.Query.HQLStringQueryPlan.HQLStringQueryPlan(string hql, string collectionRole, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> enabledFilters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 16 + 0x3e Bytes C#
NHibernate.dll!NHibernate.Engine.Query.HQLStringQueryPlan.HQLStringQueryPlan(string hql, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> enabledFilters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 14 C#
NHibernate.dll!NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(string queryString, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> enabledFilters) Zeile 61 + 0x5b Bytes C#
NHibernate.dll!NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(string query, bool shallow) Zeile 304 + 0x87 Bytes C#
NHibernate.dll!NHibernate.Impl.AbstractSessionImpl.CreateQuery(string queryString) Zeile 283 + 0x3b Bytes C#
在Hql中使用这样的别名是否有问题?是否存在不允许使用与实体名称相同的别名的语法?似乎Nhibernate尝试为别名找到一个persister,这显然不起作用。
答案 0 :(得分:1)
您使用的别名不一样:&#34; physikalischesObjekt&#34;和#34; physikalisachesobjekt&#34;。