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

前端之家收集整理的这篇文章主要介绍了java – HQL中的括号不能转换为SQL前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的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知道它,并删除括号.

你不需要那些括号.

原文链接:https://www.f2er.com/java/121930.html

猜你在找的Java相关文章