baseHeaderStmt = connection.prepareStatement(STMT_INSERT_HEADER_BASE,
Statement.RETURN_GENERATED_KEYS);
Iterator<HeaderEntry> it = headers.iterator();
while (it.hasNext()) {
HeaderEntry entry = it.next();
SpillableString name = entry.getName();
SpillableString value = entry.getValue();
baseHeaderStmt.setLong(1, eventId);
baseHeaderStmt.setString(2, name.getBase());
baseHeaderStmt.setString(3, value.getBase());
baseHeaderStmt.setBoolean(4, name.hasSpill());
baseHeaderStmt.setBoolean(5, value.hasSpill());
int updateCount = baseHeaderStmt.executeUpdate();
if (updateCount != 1) {
throw new JdbcChannelException("Unexpected update header count: "
+ updateCount);
}
ResultSet headerIdResultSet = baseHeaderStmt.getGeneratedKeys();
if (!headerIdResultSet.next()) {
throw new JdbcChannelException(
"Unable to retrieve inserted header id");
}
long headerId = headerIdResultSet.getLong(1);
entry.setId(headerId);
if (name.hasSpill()) {
headerWithNameSpill.add(entry);
}
if (value.hasSpill()) {
headerWithValueSpill.add(entry);
}
}
// Persist header name spills