public void testPerformNonSelectingQueryCounts2() throws Exception {
createArtistsDataSet();
SQLTemplate query = new SQLTemplate(
Painting.class,
"INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ARTIST_ID, ESTIMATED_PRICE) "
+ "VALUES ($pid, '$pt', $aid, #bind($price 'DECIMAL' 2))");
Map<String, Object>[] maps = new Map[3];
for (int i = 0; i < maps.length; i++) {
maps[i] = new HashMap<String, Object>();
maps[i].put("pid", new Integer(1 + i));
maps[i].put("pt", "P-" + i);
maps[i].put("aid", new Integer(33002));
maps[i].put("price", new BigDecimal("1." + i));
}
// single batch of parameters
query.setParameters(maps);
int[] counts = context.performNonSelectingQuery(query);
assertNotNull(counts);
assertEquals(maps.length, counts.length);
for (int i = 0; i < maps.length; i++) {
assertEquals(1, counts[i]);
}
SQLTemplate delete = new SQLTemplate(Painting.class, "delete from PAINTING");
counts = context.performNonSelectingQuery(delete);
assertNotNull(counts);
assertEquals(1, counts.length);
assertEquals(3, counts[0]);
}