TableQuery tQuery = new TableQuery("people", connectionPool,
SQLTestsConstants.sqlGen);
// In this test the primary key is used as a version column
tQuery.setVersionColumn("ID");
SQLContainer container = new SQLContainer(tQuery);
container.setAutoCommit(false);
/* Check that the container size is correct and there is no 'Viljami' */
Assert.assertEquals(4, container.size());
List<Filter> filters = new ArrayList<Filter>();
filters.add(new Equal("NAME", "Viljami"));
tQuery.setFilters(filters);
Assert.assertEquals(0, tQuery.getCount());
tQuery.setFilters(null);
/* Fetch first item, modify and commit */
Object item = container.getItem(container.getItemIds().iterator()
.next());
Assert.assertNotNull(item);
RowItem ri = (RowItem) item;
Assert.assertNotNull(ri.getItemProperty("NAME"));
ri.getItemProperty("NAME").setValue("Viljami");
container.commit();
// Check that the size is still correct and only 1 'Viljami' is found
Assert.assertEquals(4, tQuery.getCount());
Assert.assertEquals(4, container.size());
tQuery.setFilters(filters);
Assert.assertEquals(1, tQuery.getCount());
}