I have a problem in named query got error org.hibernate.HibernateException
: Errors in named queries: customers.amountDeposit
, customers.amountWithdraw
Here is my Namedqueries of deposit and withdrawal of amount and DAO implementation of amountdeposit and amountwithdrawal, tried for the first time, i can say I'm beginner to this
@NamedQueries ({
@NamedQuery(name="customers.amountWithdraw", query="update customers set customerBalance = customerBalance - :amount where :customerAccNo"),
@NamedQuery(name="customers.amountDeposit", query="update customers set customerBalance = customerBalance + :amount where :customerAccNo" )})
And here is my DAO implementation
public Customer amountWithdraw(Customer customer,double amount) {
customer=(Customer) session.get(Customer.class, customer.getCustomerAccNo());
if(customer!=null) {
Query query = session.getNamedQuery("customers.amountWithdraw");
query.setParameter("customerBalance",customer.getCustomerBalance());
query.setParameter("amount", amount );
query.setParameter("customerAccNo",customer.getCustomerAccNo());
query.executeUpdate();
customer=getCustomerByAccNo(customer.getCustomerAccNo());
return customer;
}
return null;
}
public Customer amountDeposit(Customer customer, double amount) {
customer=(Customer) session.get(Customer.class, customer.getCustomerAccNo());
if(customer!=null) {
Query query = session.getNamedQuery("customers.amountDeposit");
query.setParameter("customerBalance",customer.getCustomerBalance());
query.setParameter("amount", amount );
query.setParameter("customerAccNo",customer.getCustomerAccNo());
query.executeUpdate();
customer=getCustomerByAccNo(customer.getCustomerAccNo());
return customer;
}
return null;
}