I mean when updating a record, the record must fullfil a certain condition. For example, when i update a user bank account, i will need to confirm the account balance must be greater than 0 before proceed the update i.e. I need to write the SQL in "update user_acc set credit=100 where balance >0". In hibernate, the only API i can find is session.update(obj) or session.update(obj, id). However, I cannot find any api to support condition clause upon a update process. Yes, I can first select the balance out and compare is greater than 0 or not. However, the balance account will be continous increase/descrease by order application as well So let the database to handle this synchronization is the most effective way.
|