'Antlr.Runtime.MismatchedTokenException' thrown when parsing HQL query

Description

The following HQL query throws this exception:

select distinct fm from ReceivedFax f join f.ReceivingFaxMachine fm
where fm.Deactivated = :deactivated and f.Status in (:new, :detached)

The exception is thrown in the Match() call of the following method:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////
public HqlParser.identifier_return identifier() // throws
RecognitionException [1]
{
HqlParser.identifier_return retval = new
HqlParser.identifier_return();
retval.Start = input.LT(1);
IASTNode root_0 = null;
IToken IDENT292 = null;
IASTNode IDENT292_tree=null;
try
{
// C:\\Users\\Steve\\Documents\\NHibernate\\nhibernate
src
\\NHibernate\\Hql\\Ast\\ANTLR
Hql.g:659:2: ( IDENT )
// C:\\Users\\Steve\\Documents\\NHibernate\\nhibernate
src
\\NHibernate\\Hql\\Ast\\ANTLR
Hql.g:659:4: IDENT
{
root_0 = (IASTNode)adaptor.GetNilNode();
IDENT292=(IToken)Match(input,IDENT,FOLLOW_IDENT_in_identifier3551);
IDENT292_tree = (IASTNode)adaptor.Create(IDENT292);
adaptor.AddChild(root_0, IDENT292_tree);
}
retval.Stop = input.LT(-1);
retval.Tree =
(IASTNode)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, (IToken)
retval.Start, (IToken) retval.Stop);
}
catch (RecognitionException ex)
{
retval.Tree = HandleIdentifierError(input.LT(1),ex);
}
finally
{
}
return retval;
}
/////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////

I've also taken the liberty of including my stack trace:

/////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.RecoverFromMismatchedToken(Antlr.Runtime .IIntStream
input =
{selectdistinctfmfromReceivedFaxfjoinf.ReceivingFaxMachinefmwherefm.Deactiv ated=:deactivatedandf.Statusin(:new,:detached)},
int ttype = 123, Antlr.Runtime.BitSet follow = {1}) Line 111 + 0x31
bytes C#
[External Code]
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.identifier() Line
10715 + 0x35 bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.primaryExpression() Line 8658 + 0xc
bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.atom() Line 8367 +
0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.unaryExpression()
Line 7478 + 0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.multiplyExpression() Line 7108 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.additiveExpression() Line 6966 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.bitwiseAndExpression() Line 6864 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.bitwiseXOrExpression() Line 6764 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.bitwiseOrExpression() Line 6664 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.bitwiseNotExpression() Line 6600 +
0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.concatenation()
Line 6420 + 0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.relationalExpression() Line 5792 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.equalityExpression() Line 5565 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.negatedExpression() Line 5468 + 0xc
bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.logicalAndExpression() Line 5307 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.logicalOrExpression() Line 5207 +
0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.expression() Line
5145 + 0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.compoundExpr()
Line 9971 + 0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.inList() Line 6259
+ 0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.relationalExpression() Line 6010 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.equalityExpression() Line 5565 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.negatedExpression() Line 5468 + 0xc
bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.logicalAndExpression() Line 5333 +
0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.logicalOrExpression() Line 5207 +
0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.expression() Line
5145 + 0xc bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.HqlParser.logicalExpression() Line 5087 + 0xc
bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.whereClause() Line
4842 + 0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.queryRule() Line
1623 + 0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.selectStatement()
Line 1227 + 0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParser.statement() Line
431 + 0xc bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlParseEngine.Parse() Line
493 + 0x10 bytes C#
NHibernate.dll!
NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(s tring
queryString = "select distinct fm from ReceivedFax f join
f.ReceivingFaxMachine fm where fm.Deactivated = :deactivated and
f.Status in (:new, :detached)", string collectionRole = null, bool
shallow = false,
System.Collections.Generic.IDictionary<string,NHibernate.IFilter>
filters = Count = 0, NHibernate.Engine.ISessionFactoryImplementor
factory = {NHibernate.Impl.SessionFactoryImpl}) Line 19 + 0x4d bytes
C#
NHibernate.dll!
NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(string
hql = "select distinct fm from ReceivedFax f join
f.ReceivingFaxMachine fm where fm.Deactivated = :deactivated and
f.Status in (:new, :detached)", string collectionRole = null, bool
shallow = false,
System.Collections.Generic.IDictionary<string,NHibernate.IFilter>
enabledFilters = Count = 0,
NHibernate.Engine.ISessionFactoryImplementor factory =
{NHibernate.Impl.SessionFactoryImpl}) Line 24 + 0x9f bytes C#
NHibernate.dll!
NHibernate.Engine.Query.HQLStringQueryPlan.HQLStringQueryPlan(string
hql = "select distinct fm from ReceivedFax f join
f.ReceivingFaxMachine fm where fm.Deactivated = :deactivated and
f.Status in (:new, :detached)", string collectionRole = null, bool
shallow = false,
System.Collections.Generic.IDictionary<string,NHibernate.IFilter>
enabledFilters = Count = 0,
NHibernate.Engine.ISessionFactoryImplementor factory =
{NHibernate.Impl.SessionFactoryImpl}) Line 16 + 0x3e bytes C#
NHibernate.dll!
NHibernate.Engine.Query.HQLStringQueryPlan.HQLStringQueryPlan(string
hql = "select distinct fm from ReceivedFax f join
f.ReceivingFaxMachine fm where fm.Deactivated = :deactivated and
f.Status in (:new, :detached)", bool shallow = false,
System.Collections.Generic.IDictionary<string,NHibernate.IFilter>
enabledFilters = Count = 0,
NHibernate.Engine.ISessionFactoryImplementor factory =
{NHibernate.Impl.SessionFactoryImpl}) Line 10 + 0x2c bytes C#
NHibernate.dll!
NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(string
queryString = "select distinct fm from ReceivedFax f join
f.ReceivingFaxMachine fm where fm.Deactivated = :deactivated and
f.Status in (:new, :detached)", bool shallow = false,
System.Collections.Generic.IDictionary<string,NHibernate.IFilter>
enabledFilters = Count = 0) Line 61 + 0x4e bytes C#
NHibernate.dll!
NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(string query =
"select distinct fm from ReceivedFax f join f.ReceivingFaxMachine fm
where fm.Deactivated = :deactivated and f.Status in
(:new, :detached)", bool shallow = false) Line 294 + 0x83 bytes C#
NHibernate.dll!
NHibernate.Impl.AbstractSessionImpl.CreateQuery(string queryString =
"select distinct fm from ReceivedFax f join f.ReceivingFaxMachine fm
where fm.Deactivated = :deactivated and f.Status in
(:new, :detached)") Line 273 + 0x37 bytes C#
Test.App.Hibernate.dll!
Test.App.Hibernate.PersistenceContext.CreateHibernateQuery(string hql
= "select distinct fm from ReceivedFax f join f.ReceivingFaxMachine
fm where fm.Deactivated = :deactivated and f.Status in
(:new, :detached)") Line 208 + 0x3c bytes C#
/////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////

MAPPING FILE:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="TestApp.Fax" namespace="TestApp.Fax">
<joined-subclass name="ReceivedFax" proxy="ReceivedFax"
table="ReceivedFax_" extends="TestApp.AttachedDocument,TestApp">
<key column="AttachedDocumentOID_" />
<property name="Status" column="Status_"
type="TestApp.Fax.Hibernate.ReceivedFaxStatusEnumHbm,
TestApp.Fax.Hibernate" not-null="true" access="nosetter.camelcase-
underscore"/>
<property name="StateChangeTime" column="StateChangeTime_"
type="DateTime" not-null="true" access="nosetter.camelcase-underscore"/

<property name="PageCount" column="PageCount_" type="int"/>
<many-to-one name="ReceivingFaxMachine" class="FaxMachine"
column="ReceivingFaxMachineOID_" not-null="true" fetch="join"/>
<property name="SenderName" column="SenderName_" type="string"
length="256"/>
<property name="SenderNumber" column="SenderNumber_" type="string"
length="32"/>
</joined-subclass>
</hibernate-mapping>

Thanks!

Environment

None

Attachments

1

Activity

Show:

Fabio Maulo 
December 20, 2010 at 3:26 AM

The class ReceivedFax does not have a property named Status.

Going to close this issue.
Please use the nhusers group for questions.
Thanks.

Fabio Maulo 
December 20, 2010 at 3:22 AM

Where is ReceivedFaxStatusEnumHbm ?
You are using it as custom IType or IUserType or ICompositeUserType.

Aaron Boxer 
December 19, 2010 at 8:17 PM

I don't use any session filters, btw.

Aaron Boxer 
December 19, 2010 at 8:16 PM

Here are the mapping file and domain classes for the FaxMachine and related entities. I've put them all into a test project, and modified the code so that the classes compile, and link to the NH 3.0 dll. Let me know if you need anything else.

Thanks very much,
Aaron

Fabio Maulo 
December 18, 2010 at 10:21 AM

ah...
if you have some active session-filters we need it too.

Not an Issue

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created November 15, 2010 at 6:56 PM
Updated December 20, 2010 at 3:26 AM
Resolved December 20, 2010 at 3:26 AM
Who's Looking?