1

我对以下 Hql 查询有疑问:

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 似乎尝试为不起作用的别名查找持久性。

4

1 回答 1

1

您使用的别名不一样:“physikalischesObjekt”和“physikalisachesobjekt”。

于 2013-04-18T13:04:42.017 回答