Article
实体是Product
实体的子类。他们的继承策略是joined
。 Article#flag
是一个布尔属性,我想为所有文章设置false。因此,我做休眠批量更新导致查询需要永久完成
Query query = entityManager.createQuery("update Article set flag=:flagValue");
query.setParameter("flagValue", false);
query.executeUpdate();
我预计这导致一个单一的SQL语句对数据库应该完成相当快。相反,Hibernate填充一个临时表(它并不在物理上存在于数据库中),并运行一个查询语句即。更新后:
insert into HT_article select article0_.id as id from schema.article article0_ inner join schema.product article0_1_ on article0_.id=article0_1_.id
update schema.article set flag=0 where (id) IN (select id from HT_article)
实际的更新语句采用“永远”来完成和锁定受影响的文章从而导致其他交易锁定异常。我的意思是永远意味着超过一个小时的13万篇文章。
这种行为的解释是什么?我如何解决这个问题?除了运行本机查询我的意思是......
更新2011-05-12:因为在查询时慢,我提交了错误的,它是非常缓慢的 - >http://opensource.atlassian.com/projects/hibernate/browse/HHH-5905
值得一提的是,也'查询查询= getEntityManager()的createQuery( “更新第一套标志=假where articleNumber in(:articleNumbers)“); query.setParameter(”articleNumbers“,articleNumbers);'导致同样非常缓慢的处理我们在HT_article表中。 – 2010-12-13 09:30:34