assertEquals(saved.getId(), updated.getId());
}
@Test
public void testVersion() {
Person person = new Person("Rembrandt", "van Rhijn", date());
personDao.add(person);
assertEquals(0, SimpleJdbcTestUtils.countRowsInTable(
simpleJdbcTemplate, "Person_TABLE"));
flush();
assertEquals(0, simpleJdbcTemplate
.queryForInt("select version from person_table where id = ?",
person.getId()));
person.setFirstName("First");
flush();
assertEquals(1, simpleJdbcTemplate
.queryForInt("select version from person_table where id = ?",
person.getId()));
person.setFirstName("Second");
flush();
assertEquals(2, simpleJdbcTemplate
.queryForInt("select version from person_table where id = ?",
person.getId()));
flush();
/*
* When nothing is changed the flush does not actually update the row,
* and "version" is not changed.
*/
assertEquals(2, simpleJdbcTemplate
.queryForInt("select version from person_table where id = ?",
person.getId()));
}