Why does this HQL delete fail, when an HQL select with same terms works?

狂风中的少年 提交于 2019-12-04 12:08:06

Try this:

delete MyLog log
where log.id in
          (select l.id
           from MyLog l
           where l.UtcTimestamp < :threshold and
           and.Configuration.Application = :application)

From the link submitted by Rafael above:

http://docs.jboss.org/hibernate/stable/core/reference/en/html/batch.html#batch-direct

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

The syntax is DELETE FROM MyLog ....

Have in mind that HQL delete does not honour cascades defined with (n)hibernate mappings.

So you can select all the entities and delete them one by one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!