Negate unary operator in Hibernate QL

I'm trying to switch boolean field using the following hql:

update Entity e set e.booleanField = not e.booleanField where e.id = ?1;

Unfortunately "QuerySyntaxException: unexpected token: not near..." was thrown.

My question is: is there some unary operator for hibernate that supports such expression? Or any well known trick?

sql supports such queries (postgresql):

update entity_table set booleanField = not(booleanField);

我只是使用本机SQL查询来做到这一点。


要在HQL / JPQL下切换boolean属性,相当于not一元运算符,请使用:

UPDATE entity e SET e.booleanField = (e.booleanField=false)
链接地址: http://www.djcxy.com/p/10678.html

上一篇: BE(荷兰比利时)不再支持(iframe像按钮)?

下一篇: 在Hibernate QL中取消一元运算符