Skip to content

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 = ?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);



I would just use a native SQL query for this.

User contributions licensed under: CC BY-SA
3 People found this is helpful