2010-09-26 11 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:

qualche idea del perché?

risposta

18

TRUNCATE TABLE non è una dichiarazione HQL valida.

Uso CreateSQLQuery invece di CreateQuery per eseguire istruzioni SQL.

+2

Sì, è la risposta giusta. –

+0

per aiuto Diego. – senzacionale

+0

Off topic: Perché NHibernate espone un'eccezione ANTLR? Come dovrebbe gestirlo l'utente? Non dovrebbe gettare un InvalidQuerySyntaxException o whatnot? –