Skip to content
Advertisement

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

Advertisement

Answer

I would just use a native SQL query for this.

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