When trying to do an HQL batch update for Order entity, I’m getting the following exception:
Specified method is not supported.
at NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.GetClassName(IASTNode querySource)
at NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.Process(IASTNode tree)
at NHibernate.Hql.Ast.ANTLR.AstPolymorphicProcessor.Process()
at NHibernate.Hql.Ast.ANTLR.AstPolymorphicProcessor.Process(IASTNode ast, ISessionFactoryImplementor factory)
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters)
at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query, Boolean shallow)
at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString)
at ...Repositories.OrderRepository.MarkAsConfirmed(IEnumerable`1 orderIds) in C:\Users\Miroslav\Documents\Projects\...\OrderRepository.cs:line 40
at ConfirmationUploadTask.Execute()
Note that the Order entity is mapped to Orders table, so there shouldn’t be any reserved-keyword related issues. Other LINQ 2 NHibernate based queries are working properly. When using some other mapped entity instead of Order, the query works.
I’ve also tried with hbm2ddl.keywords=auto-quote as mentioned by Fabio, but with no luck.
For reference, this is what the query looks like:
var query = GetSession().CreateQuery(
"update Order set IsConfirmed = :isConfirmed where id in (:ids)");
When using CreateSQLQuery instead, it works without errors:
var query = GetSession().CreateSQLQuery(
"UPDATE Orders SET IsConfirmed = :isConfirmed WHERE OrderId in (:ids)");
Any ideas?
I believe it’s a bug; please open a ticket at http://jira.nhforge.org
As a workaround, qualify the name of the Order entity. Example: