Reputation: 2262
I have a table with a column that holds int values, I need to know how to write a JPQL query that, instead of overriding the existing value, it add the new value to the existing one and persist the sum. Here is the JPQL that sets a value.
UPDATE Transaction t SET t.amount = :amount WHERE t.id = :id
Upvotes: 0
Views: 731
Reputation: 691933
Just like in SQL:
UPDATE Transaction t SET t.amount = t.amount + 1 WHERE t.id = :id
Upvotes: 3