加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – HQL中的括号不能转换为SQL

发布时间:2020-12-14 05:36:52 所属栏目:Java 来源:网络整理
导读:这是我的HQL: Query query = createQueryOnCurrentSession("DELETE Email e " + "where " + "(status = :sent and creationTime = :creation)" + "or " + "(status = :error and maxEttempts = :maxEttempts)"); 这是生成的SQL: delete from `email` where
这是我的HQL:
Query query = createQueryOnCurrentSession("DELETE Email e " +
                "where " +
                "(status = :sent and creationTime <= :creation)" +
                "or " +
                "(status = :error and maxEttempts >= :maxEttempts)");

这是生成的SQL:

delete from `email` where `status`=? and `creation_time`<=? or `status`=? and `attempts`>=?

问题:为什么括号不在SQL中?
我希望它是:

delete from `email` where (`status`=? and `creation_time`<=?) or (`status`=? and `attempts`>=?)

也许我会在2个请求中删除?

delete from `email` where `status`=? and `creation_time`<=?
delete from `email` where `status`=? and `attempts`>=?

解决方法

这实际上是一个功能.

由于和优先于或,hibernate知道它,并删除括号.

你不需要那些括号.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读