Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nhibernate - How to debug "Antlr.Runtime.NoViableAltException"?

Tags:

hql

nhibernate

With many HQL queries, time and time again I am getting this exception:

Antlr.Runtime.NoViableAltException

This is really generic and unhelpful - does anyone know how best to debug this? Obviously it's a problem with my HQL - but without any clue as to what exactly is wrong it's very much a case of trial and error. I'm pulling my hair out every time I see this.

Note, I don't want to post any HQL here, becuase it's something that I am often coming across, not a problem related to one query.

Does anyone know the best way to tackle this? Is there any tool for validating HQL queries?

like image 454
UpTheCreek Avatar asked Dec 07 '22 05:12

UpTheCreek


2 Answers

Have a look at NHibernate Query Analyzer. It is not perfect, but it will be helpful in many situations.

like image 132
kgiannakakis Avatar answered Jan 10 '23 16:01

kgiannakakis


I can't help you directly, here's something I can share.

When dealing with hibernate or nhibernate (NH), I generally debug by enabling logging on the nhibernate's log4net, or/and the logging of queries at the DB side (e.g. mysql).

They can tell me what is the queries being formulated and executed at the DB and what are the exceptions thrown back by the DB.

like image 32
o.k.w Avatar answered Jan 10 '23 15:01

o.k.w