Java HQL中的括号未转换为SQL

Java HQL中的括号未转换为SQL,java,hibernate,Java,Hibernate,这是我的HQL: Query query = createQueryOnCurrentSession("DELETE Email e " + "where " + "(status = :sent and creationTime <= :creation)" + "or " + "(status = :error and maxEttempts >= :m

这是我的HQL:

Query query = createQueryOnCurrentSession("DELETE Email e " +
                "where " +
                "(status = :sent and creationTime <= :creation)" +
                "or " +
                "(status = :error and maxEttempts >= :maxEttempts)");
Query Query=createQueryOnCurrentSession(“删除电子邮件e”+
“哪里”+
“(状态=:已发送且creationTime=:maxEttempts)”;
以下是生成的SQL:

delete from `email` where `status`=? and `creation_time`<=? or `status`=? and `attempts`>=?
从'email'中删除,其中'status`=?和“创建时间”=?
问题:为什么SQL中没有括号? 我希望是:

delete from `email` where (`status`=? and `creation_time`<=?) or (`status`=? and `attempts`>=?)
从'email'中删除('status`=?和'creation\u time`=?)
作为备选方案,我将在2个请求中删除

delete from `email` where `status`=? and `creation_time`<=?
delete from `email` where `status`=? and `attempts`>=?
从'email'中删除,其中'status`=?和“创建时间”=?

这实际上是一项功能

由于
优先于
,所以hibernate知道这一点,并删除括号


您不需要这些括号。

逻辑运算符,其优先级高于逻辑运算符或

对于运算符优先级,请遵循链接

http://dev.mysql.com/doc/refman/5.0/en/operator-precedence.html
http://msdn.microsoft.com/en-us/library/ms190276.aspx

http://docs.oracle.com/html/A85397_01/operator.htm#997691

试着像这样转义括号:
\(
single
”\(“
当然不编译)和double
”\(“
抛出异常:
org.hibernate.QueryException:unexpected char:“\”[DELETE com.grroo.model.Email e where\(状态=:sent和creationTime=:maxturents\)]
我想你可以附加查询字符串作为条件,然后执行。我知道在某些数据库中是这样的……但这是我将使用的所有数据库的标准吗?你能参考一下吗?我找不到它……我不确定它是否是固定标准,但DBs必须这样使用。这正是困扰我的地方。也许有办法告诉hibern如果有一个数据库以不同的方式处理事情,那么该数据库的Hibernate方言可以容纳它。这里只有最大的3DB提供商,它们当然使用该标准。