let's say I have entity Person.
When I try to use with hibernate createQuery, it remove ( ) in where condition. Example:
Query query = session.createQuery("FROM Person WHERE name=? OR (id=? AND active=?)");
query.setParameter(1, "Test");
query.setParameter(2, 1);
que开发者_JS百科ry.setParameter(3, 1);
// and so on
When I open debug sql output in hibernate, it produces
where person0_.`name`=? or person0_.`id`=? and person0_.`active`=?
Cause I put () inside the where condition, the output should be
where person0_.`name`=? or (person0_.`id`=? and person0_.`active`=?)
why the () in where condition is removed? or am I miss something?
Thanks
AND has a higher precedence than OR in SQL so the two statements are equivalent. Hibernate removes the unnecessary parentheses.
精彩评论