List users = loadAllObject(User.class);
assertTrue("Empty User table.", users.size() > 0);
// 2. update:
// UserHome fixture = getUserHome();
User result = (User) users.get(0);
String oldUserName = result.getUsername();
String newUserName = oldUserName + "unitTest";
Long id = result.getId();
result.setUsername(newUserName);
// force commit immeidately, important:
setComplete();
endTransaction();
logger.info("user updated: " + result.getUsername() + "id = " + result.getId());
// 2. verify
String sqlStr = "select username from public.user where user_id=" + result.getId();
String verifyName = (String) jdbcTemplate.queryForObject(sqlStr, String.class);
assertTrue("verify failed.", newUserName.equals(verifyName));
// 3. undo update:
// need to call onSetUp() to start a new session/Tx:
onSetUp();
result = (User) loadObject(User.class, id);
result.setUsername(oldUserName);
setComplete();
endTransaction();
// 4. verify undo:
verifyName = (String) jdbcTemplate.queryForObject(sqlStr, String.class);