2010-09-26 14 views
5
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.Antlr.Runtime.NoViableAltException nhibernate

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

Source Error:

alguna idea de por qué?

Respuesta

18

TRUNCATE TABLE no es una declaración HQL válida.

Use CreateSQLQuery en lugar de CreateQuery para ejecutar instrucciones SQL.

+2

Sí, esa es la respuesta correcta. –

+0

thx para ayuda Diego. – senzacionale

+0

Fuera de tema: ¿Por qué NHibernate expone una excepción ANTLR? ¿Cómo se supone que el usuario debe manejar eso? ¿No debería lanzar una InvalidQuerySyntaxException o algo así? –