// Use a single connection so that LAST_INSERT_ID works.
QueryRunner runner = new QueryRunner();
Connection conn = Application.getDB().getDataSource().getConnection();
runner.update(conn, "UPDATE report_observation SET errorId = NULL WHERE 1=1");
runner.update(conn, "DELETE FROM report_error WHERE 1=1");
Collection<Report> reports = runner.query(conn, "SELECT * FROM report order by time ASC", reportHandler);
for (Report report : reports) {
logger.info("Generating errors for report: "+report);
Collection<ReportError> oldOpenErrors = runner.query(conn, "SELECT * FROM report_error WHERE closedAt IS NULL" , reportErrorHandler);