1 | public void updateAccountBranch(Integer id, String branch) throws Exception↵ | | 1 | public void updateAccountBalance(Integer id, Integer newBalance) throws Exception↵
|
2 | {↵ | | 2 | {↵
|
3 | log.debug("Updating account " + id + " to branch " + branch);↵ | | 3 | log.debug("Updating account " + id + " to balance " + newBalance);↵
|
4 | tm.begin();↵ | | 4 | tm.begin();↵
|
5 | try {↵ | | 5 | try {↵
|
6 | Session session = sessionFactory.getCurrentSession();↵ | | 6 | Session session = sessionFactory.getCurrentSession();↵
|
7 | Object account = session.get(acctClass, id);↵ | | 7 | Object account = session.get(acctClass, id);↵
|
8 | setBranch.invoke(account, branch);↵ | | 8 | setBalance.invoke(account, newBalance);↵
|
9 | session.update(account);↵ | | 9 | session.update(account);↵
|
10 | tm.commit();↵ | | 10 | tm.commit();↵
|
11 | }↵ | | 11 | }↵
|
12 | catch (Exception e) {↵ | | 12 | catch (Exception e) {↵
|
13 | log.error("rolling back", e);↵ | | 13 | log.error("rolling back", e);↵
|
14 | tm.rollback();↵ | | 14 | tm.rollback();↵
|
15 | throw e;↵ | | 15 | throw e;↵
|
16 | }↵ | | 16 | }↵
|
17 | log.debug("Updated account " + id + " to branch " + branch);↵ | | 17 | log.debug("Updated account " + id + " to balance " + newBalance);↵
|
18 | | | 18 |
|