这里是我的HQL:括号HQL不ntranslated到SQL
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`>=?
试图逃避括号就像这样:'\(' –
单'” \(“'不编译(当然)和双'”\\(“'throw exception:'org.hibernate.QueryException:unexpected char:'\'[DELETE com.grroo.model.Email e where \ status =:sent and creationTime <=:creation \)或\(status =:error and attempts> =:maxAttempts \)]' – urir
我想你可以附加查询字符串作为您的条件,然后执行 –