public int[] dowork(final List<User> list) { final List<int[]> results = new ArrayList<int[]>(); getSession().doWork(new Work(){ public void execute(Connection connection) throws SQLException { final String sql="update test_user set user_name=? where id=?"; PreparedStatement p = connection.prepareStatement(sql); for(int i=0;i<list.size();i++) { System.out.println(list.get(i).getUserName()+"---"+list.get(i).getId()); p.setString(1, list.get(i).getUserName()+i); p.setInt(2, list.get(i).getId()); p.addBatch(); } results.add(p.executeBatch()); } }); return results.get(0); }