@Test public void testLazyNameUpdate() { Personne p = (Personne) getSession().get(Personne.class, 1000); p.setLazyName("Arthur"); getSession().flush(); SqlRowSet rs = jdbcTemplate.queryForRowSet("select * from pers1 where id = ?", 1000); rs.next(); assertEquals(rs.getString("LAZYNAME"), "Arthur", "Must have been updated"); assertEquals(rs.getString("NAME"), "Anybody", "Must not change"); }
@Test public void testInsert() { Personne p = new Personne(); p.setName("test"); p.setLazyName("testlazy"); getSession().saveOrUpdate(p); getSession().flush(); // Test cheat assertNotNull(p.getId()); SqlRowSet rs = jdbcTemplate.queryForRowSet("select * from pers1 where id = ?", p.getId()); rs.next(); assertEquals(rs.getString("NAME"), "test", "Must have been inserted"); assertEquals(rs.getString("LAZYNAME"), "testlazy", "Must have been inserted"); }