I'd like to create query like this with QueryDSL
update WorkMessage w set w.totalPrice = 0.12 - w.totalCost;
I tried like this
Expression<Float> priceExpr = Expressions.constant(0.12f);
new JPAUpdateClause(em, w)
.set(w.totalPrice , priceExpr.subtract(w.totalCost));
But this doesn't work - Expression doesn't have subtract method.
I did it like this:
new JPAUpdateClause(em, w)
.set(w.totalPrice , w.totalCost.subtract(0.12f).negate());
but I'd like to know how to do it the first way.
//EDit
The second way don't work:
JPAUpdateClause.toString says:
update WorkMessage workMessage
set workMessage.totalPrice = -(workMessage.totalCost - :a1)
but the SQL result is
update work_message set total_price=-total_cost-?
Parentheses just dissapeared. Am I doing something wrong? It looks like theese:
w.totalCost.subtract(0.12f).negate()
w.totalCost.negate().subtract(0.12f)
have the same result.
For the above problem
w.totalCost.negate().add(0.12f)
works. But I think there is a bug.