NHibernate HQL批量更新失败,返回“0”;不支持指定的方法";例外
尝试对Order实体执行HQL批处理更新时,出现以下异常:NHibernate HQL批量更新失败,返回“0”;不支持指定的方法";例外,nhibernate,hql,Nhibernate,Hql,尝试对Order实体执行HQL批处理更新时,出现以下异常: Specified method is not supported. at NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.GetClassName(IASTNode querySource) at NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.Process(IASTNode tree)
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()
请注意,订单实体映射到订单表,因此不应存在任何保留关键字相关问题。其他基于LINQ 2 NHibernate的查询工作正常。当使用其他映射实体而不是订单时,查询将起作用
我也尝试过hbm2ddl.keywords=auto quote
,但没有成功
作为参考,以下是查询的外观:
var query = GetSession().CreateQuery(
"update Order set IsConfirmed = :isConfirmed where id in (:ids)");
改用CreateSQLQuery时,它可以正常工作,不会出现错误:
var query = GetSession().CreateSQLQuery(
"UPDATE Orders SET IsConfirmed = :isConfirmed WHERE OrderId in (:ids)");
有什么想法吗?我认为这是一个bug;请在 作为一种变通方法,请限定订单实体的名称。例如:
update MyProj.Domain.Order set IsConfirmed = :isConfirmed where id in (:ids)
我相信这是一只虫子;请在 作为一种变通方法,请限定订单实体的名称。例如:
update MyProj.Domain.Order set IsConfirmed = :isConfirmed where id in (:ids)
非常感谢。您的解决方案按预期工作。我向吉拉提交了一个bug:谢谢!您的解决方案按预期工作。我向JIRA提交了一个bug: