`Article` entity is a sub-class of the `Product` entity. The inheritance strategy for them is `joined`. `Article#flag` is a boolean attribute which I want to set false for all articles. Hence, I do
Code:
Query query = entityManager.createQuery("update Article set flag=:flagValue");
query.setParameter("flagValue", false);
query.executeUpdate();
I expected this to lead to a single SQL statement against the database which should complete fairly quickly - at least it does if I run the update against the database directly. Instead, Hibernate populates a temporary HT_ table and runs an in-query ie. the update later:
Code:
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)
The actual update statement takes "forever" to complete and locks the affected articles thereby causing lock exceptions in other transactions. By forever I mean more than an hour for 130000 articles.
What's the explanation for this behavior and how could I solve it? Other than running a native query I mean...