Hibernate delete and update queries with joins

From Hibernate 4.1.9 manual - section about bulk update and deletes:

No implicit or explicit joins can be specified in a bulk HQL query. Sub-queries can be used in the where-clause, where the subqueries themselves may contain joins.

Unsupported (implicit join)

DELETE A a WHERE a.relation.property = "dummy";

A way to go

DELETE A a WHERE a.relation.id IN (SELECT r.id FROM Relation r WHERE r.property = "dummy");

Comments

  1. I presume your example 1 is supposed to be a join with some other table here?

    ReplyDelete
  2. I presume your example 1 is supposed to be a join with some other table here?

    ReplyDelete
  3. Thanks! I found that post after googling for about one hour and it solved my problem with an update HQL query.

    ReplyDelete
  4. Great help. Saved a lot of my time I would have wasted debugging my code.

    ReplyDelete

Post a Comment

Popular posts from this blog

Access application Google Drive account from javascript without client side authorization dialog

How to set width of a table within Twitter Bootstrap