2011-03-03 53 views
0

當試圖做Order實體的HQL批更新,我得到以下異常:NHibernate的HQL批更新失敗,「指定的方法不支持」異常

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查詢工作正常。當使用其他映射實體而不是Order時,查詢將起作用。

我也試過hbm2ddl.keywords=auto-quoteas mentioned by Fabio,但沒有運氣。

以供參考,這是查詢的樣子:

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)"); 

任何想法?

回答

3

我相信這是一個錯誤;請打開票http://jira.nhforge.org

作爲解決方法,限定訂單實體的名稱。例如:

update MyProj.Domain.Order set IsConfirmed = :isConfirmed where id in (:ids) 
+0

謝謝!您的解決方法按預期工作。我向JIRA提交了一個錯誤:http://216.121.112.228/browse/NH-2562 – 2011-03-06 17:13:28

相關問題