@Test
public void testPreparedBatch() {
h.configure(SqlStatements.class, c -> c.setSqlLogger(SqlLogger.NOP_SQL_LOGGER));
h.createUpdate(CREATE).define("x", "foo").execute();
h.configure(SqlStatements.class, c -> c.setSqlLogger(logger));
int id = 0;
h.prepareBatch("insert into <x>(bar) values(?)")
.define("x", "foo")
.bind(0, new Argument() {
@Override
public void apply(int position, PreparedStatement statement, StatementContext ctx) throws SQLException {
statement.setInt(1, id);
}
@Override
public String toString() {
return Objects.toString(id);
}
})
.execute();
assertThat(logger.getAttributes())
.hasSize(2)
.allMatch(x -> x.get("x").equals("foo"))
.allMatch(x -> x.size() == 1);
assertThat(logger.getBindings()).containsExactly(String.valueOf(id), String.valueOf(id));
}