hibernate - How to update columns value with new value -
i update column value new entity value incrementally, example:
support have table user column name balance
for specific user, balance 3000.
now, set value 3500.
i have hibernate "user" entity has 'balance' value of 500.
how can make update??
if make using pure sql query, simple do:
"update user set balance = balance+500 user_id=3"
i avoid calling sql , use hibernate.
have tried below code? remeber mention possible solutions tried before asking question.
user user=session.get(user.class, 3); // 3 id of user. user.setbalance((user.getbalance()+500)); session.saveorupdate(user); session.commit();