這裏是我的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
我想你可以附加查詢字符串作爲您的條件,然後執行 –