Thursday, 15 September 2011

java - How can I add a value to a column? -


I want to add a value to an existing column, but I do not want to choose it first. Right now I have to do something like Employee in a named query

  // run hql where id =: id // the above e 100) after running the service bonus (E. T. Bonus ()); // Add 100 bonus / / database of HibernateUtil.SaveOrUpdate (E) to E;  

But I should do something that has just done one more thing

  update worker and e.bonus = e.bonus + 100 < / Code> 

Is this something I can do in hibernate? if so, how. If not, what is the best practice suggested for such updates?

You can create an HQL query that only performs an update

 < Code> query update bonus = security ("Employee SET bonus = update bonus + 100 WHERE id =: id"); UpdateBonus.setInteger ("id", employee .getId ()); UpdateBonus.executeUpdate ();  

No comments:

Post a Comment