Reputation: 123
I would like to know how to create an update named query to update a record in a derby db.
Here is my scenario, i have a table called account in a database named bank. In the account table there are 2 columns, account id and balance.
I want to type an update query which will update the balance of a record using the account id. I am familiar with sql queries but not with named queries.
Here is what I have created
@NamedQuery(name="Accountcb004415.updateBalance",
query="UPDATE Accountcb004415
set a.balance = :balance WHERE a.accountid= :accountid")
However the above query doesn't work. What seems to be wrong here ?
Upvotes: 0
Views: 915
Reputation: 8229
I guess you have missed identification variable a
in the query definition. In other words entity name needs to be aliased with value a
. Try this:
UPDATE Accountcb004415 a
set a.balance = :balance WHERE a.accountid= :accountid
Upvotes: 1