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.NHibernate Antlr.Runtime.NoViableAltException

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

Source Error:

jakiś pomysł dlaczego?

Odpowiedz

18

TRUNCATE TABLE nie jest prawidłową instrukcją HQL.

Użyj CreateSQLQuery zamiast CreateQuery do wykonywania instrukcji SQL.

+2

Tak, to jest właściwa odpowiedź. –

+0

thx za pomoc Diego. – senzacionale

+0

Wyłączony temat: Dlaczego usługa NHibernate udostępnia wyjątek ANTLR? W jaki sposób użytkownik ma sobie z tym poradzić? Czy nie powinien on rzucić wyjątku InvalidQuerySyntaxException? –