Reputation: 54
I'm trying to execute this HQL query:
"from Order as order join order.Services as services"
but anytime I'm using a join I get this exception:
[QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 20]
NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException() +118
NHibernate.Hql.Ast.ANTLR.HqlParseEngine.Parse() +490
NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) +89
NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) +88
NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) +71
NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) +50
NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters) +241
NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query, Boolean shallow) +179
NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString) +160
BL.Queue.GetOrders() in c:\Yayasoft\YTour\YTour\BL\Queues\Queue.cs:66
YTourWeb.Test.Page_Load(Object sender, EventArgs e) in c:\Yayasoft\YTour\YTour\YTourWeb\Test.aspx.cs:16
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
This happens when I add a join (any join) if I do a select with no join it works.
Both entities are mapped so it's not the problem of trying to join unmapped properties
any ideas?
Upvotes: 0
Views: 186
Reputation: 123891
In this case, I would say, that the word order
is incorrectly evaluated as a part of the ORDER BY
. Try to use different alias, e.g. orderX :
var hql = "from Order as orderX join orderX.Services as services"
Upvotes: 2