ANTLR Query SyntaxException

1,214 views
Skip to first unread message

adressin

unread,
Aug 5, 2009, 1:42:20 PM8/5/09
to nhusers
Hello,

I just upgraded to NHibernate 2.1 and am now getting an error on a
query that use to work. Any ideas? Thanks in advance.

-Aaron

NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type
'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 7
[SELECT from Tradewinds.Samms.Core.Domain.TransactionHeader as tHeader
where tHeader in ( SELECT DISTINCT tDetail.TransactionHeader from
Tradewinds.Samms.Core.Domain.TransactionDetail as tDetail where
tDetail in (select tap.TransactionDetailRecord from
Tradewinds.Samms.Core.Domain.TransactionApprovalHistory as tap where
tap.ApprovalStatus = :approvalStatus and tap.RouteEntry.User.UsrCode
= :approver ) )]
at NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException()
at NHibernate.Hql.Ast.ANTLR.HqlParseEngine.Parse()
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Parse(Boolean
isFilter)
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile
(IDictionary`2 replacements, Boolean shallow, String collectionRole)
at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, String
collectionRole, Boolean shallow, IDictionary`2 enabledFilters,
ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, Boolean
shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor
factory)
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String
queryString, Boolean shallow, IDictionary`2 enabledFilters)
at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String
query, Boolean shallow)
at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String
queryString)

Fernando Zago

unread,
Aug 5, 2009, 4:14:29 PM8/5/09
to nhu...@googlegroups.com
query ?

paste the query here !

---
Vision without action is a waking dream. Action without vision is a nightmare.

adressin

unread,
Aug 5, 2009, 4:36:24 PM8/5/09
to nhusers
Thanks for the reply... the query never makes it through the parser,
so there is no sql query. The hql query is above in the stack trace.



On Aug 5, 1:14 pm, Fernando Zago <nan...@gmail.com> wrote:
> query ?
> paste the query here !
>
> ---
> Vision without action is a waking dream. Action without vision is a
> nightmare.
>

Fabio Maulo

unread,
Aug 5, 2009, 10:17:53 PM8/5/09
to nhu...@googlegroups.com
I have done this
The exception say " near line 1, column 7"
and I found
"SELECT from"
That is a clear wrong HQL since between "SELECT" and "from" you put what you are selecting or you should start directly with "from".

2009/8/5 adressin <luvn...@gmail.com>



--
Fabio Maulo

adressin

unread,
Aug 6, 2009, 12:17:27 AM8/6/09
to nhusers
Duh... thanks for the extra eyes!

-Aaron

On Aug 5, 7:17 pm, Fabio Maulo <fabioma...@gmail.com> wrote:
> I have done thisThe exception say " near line 1, column 7"
> and I found
> "SELECT from"
> That is a clear wrong HQL since between "SELECT" and "from" you put what you
> are selecting or you should start directly with "from".
>
> 2009/8/5 adressin <luvnsu...@gmail.com>

Dotan N.

unread,
Dec 3, 2009, 4:23:53 PM12/3/09
to nhu...@googlegroups.com
sorry to bring this up but i'm having similar issues with the suggested fix:

Session.Delete(string.Format("from Tokens where UserId = {0}", userId));

same exception. any idea?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---


Darius Damalakas

unread,
Dec 14, 2009, 3:48:37 AM12/14/09
to nhusers
I had the same issue just now. The HQL query in question was:
select qg
from QuestionGroup qg
inner join qg.SurveyItems as si
inner join si.SurveyPage as sp
inner join sp.Survey as survey
where survey.ID in :surveyIds

And i got also NHibernate.Hql.Ast.ANTLR.QuerySyntaxException :
Exception of type 'Antlr.Runtime.NoViableAltException' was thrown.
near line 7, column 23.

Of course, this type of exception simply does not help to understand
what is actually wrong here. A more specific exception would help.
The reason for this error was that the parameter must be surrounded by
parenthesis, since it does not happen automatically

The working query looks like this:
select qg
from QuestionGroup qg
inner join qg.SurveyItems as si
inner join si.SurveyPage as sp
inner join sp.Survey as survey
where survey.ID in (:surveyIds)


Hope that gives some ideas.





On 3 Gruo, 23:23, "Dotan N." <dip...@gmail.com> wrote:
> sorry to bring this up but i'm having similar issues with the suggested fix:
>
> Session.Delete(string.Format("from Tokens where UserId = {0}", userId));
>
> same exception. any idea?
>
> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>

Fabio Maulo

unread,
Dec 14, 2009, 7:30:53 AM12/14/09
to nhu...@googlegroups.com
I have the same problem in VisualStudio
if a<5
can't compile.

"The reason for this error was that the parameter must be surrounded by parenthesis, since it does not happen automatically"

2009/12/14 Darius Damalakas <darius.d...@gmail.com>
--


You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.





--
Fabio Maulo

Aykut Soysal

unread,
Jan 20, 2010, 6:33:33 AM1/20/10
to nhusers
I have a similar problem:

s.Delete("from Object o");

when i call this, i get an exception

NHibernate.Hql.Ast.ANTLR.QuerySyntaxException : Exception of type
'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 5
[from Object o]

stacktrace:


at NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException()
at NHibernate.Hql.Ast.ANTLR.HqlParseEngine.Parse()
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Parse(Boolean
isFilter)
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile
(IDictionary`2 replacements, Boolean shallow, String collectionRole)
at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, String
collectionRole, Boolean shallow, IDictionary`2 enabledFilters,
ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, Boolean
shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor
factory)
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String
queryString, Boolean shallow, IDictionary`2 enabledFilters)
at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query,
Boolean shallow)

at NHibernate.Impl.SessionImpl.List(String query, QueryParameters
queryParameters, IList results)
at NHibernate.Impl.SessionImpl.List(String query, QueryParameters
parameters)
at NHibernate.Impl.SessionImpl.Find(String query, Object[] values,
IType[] types)
at NHibernate.Impl.SessionImpl.Delete(String query, Object[] values,
IType[] types)
at NHibernate.Impl.SessionImpl.Delete(String query)

it says column 5 but it "Object" do i need some special syntax? i try
to use paranthesis in various combinations but i guess its only for
parameters...
am i missing something?

i am using NHibernate 2.1.2.4000 (2.1.2.4000)

thanks,

On Dec 14 2009, 2:30 pm, Fabio Maulo <fabioma...@gmail.com> wrote:
> I have the same problem in VisualStudio
> if a<5
> can't compile.
>
> "The reason for this error was that the parameter must be surrounded
> by parenthesis,
> since it does not happen automatically"
>

> 2009/12/14 Darius Damalakas <darius.damala...@gmail.com>

> > > > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com­>
> > <nhusers%2Bunsu...@googlegroups.com<nhusers%252Bunsubscribe@googlegroup­s.com>


>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en
> > > > -~----------~----~----~----~------~----~------~--~---
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to nhu...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com­>

Yonah Wahrhaftig

unread,
Jan 20, 2010, 7:04:14 AM1/20/10
to nhu...@googlegroups.com
I had a similar problem once with select.
Try
s.Delete("from Object as o");
if it is the same problem that should solve it.

Aykut Soysal

unread,
Jan 21, 2010, 3:20:47 AM1/21/10
to nhusers
I tried your suggestion, but it's not working also, I got the same
exception...
Reply all
Reply to author
Forward
0 new messages