Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nhibernate Antlr.Runtime.NoViableAltException

Tags:

c#

nhibernate

return NHibernateSession.CreateQuery(@"TRUNCATE TABLE dbo.Exceptions").ExecuteUpdate();

Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [TRUNCATE TABLE Exceptions] Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [TRUNCATE TABLE Exceptions]

Source Error:

any idea why?

like image 291
senzacionale Avatar asked Sep 26 '10 17:09

senzacionale


1 Answers

TRUNCATE TABLE is not a valid HQL statement.

Use CreateSQLQuery instead of CreateQuery to execute SQL statements.

like image 128
Diego Mijelshon Avatar answered Oct 04 '22 04:10

Diego Mijelshon