Java JPQL:向数据库中已有的值添加一个 int 值
Java JPQL: add an int value to the already existing one in Database
我有一个 table,其中有一列包含 int 值,我需要知道如何编写 JPQL 查询,而不是覆盖现有值,而是将新值添加到现有值,然后坚持总和。这里是设置一个值的JPQL。
UPDATE Transaction t SET t.amount = :amount WHERE t.id = :id
就像在SQL中一样:
UPDATE Transaction t SET t.amount = t.amount + 1 WHERE t.id = :id
我有一个 table,其中有一列包含 int 值,我需要知道如何编写 JPQL 查询,而不是覆盖现有值,而是将新值添加到现有值,然后坚持总和。这里是设置一个值的JPQL。
UPDATE Transaction t SET t.amount = :amount WHERE t.id = :id
就像在SQL中一样:
UPDATE Transaction t SET t.amount = t.amount + 1 WHERE t.id = :id