Reputation: 811
I want to do an update on a certain column in my table in the database and do some simple arithmetic operation like add.But my column is nullable
.
So in order not to have a error i need to check first if it is null.
I bump into nullif
function in hibernate but i don't know the usage of this.
Anybody know the usage of nullif
?
I wanted to use this in update HQL
statement to check if the column is null and then perform an addition on the field.
Thanks. :)
Upvotes: 1
Views: 6722
Reputation: 30813
the signature is nullif(column, "valueifcolumn is null")
so in update do Update x set x.y = nullif(x.z, 0) + 123
Upvotes: 1