Source:
<code>public Map<Dependency, FileValidationStatus> getValidationStatuses(final Set<Dependency> deps, final String validationKey) throws SQLException { Map<Dependency, FileValidationStatus> depValidationStatuses = new HashMap<>(); if (deps.isEmpty()) { return depValidationStatuses; } Map<String, Dependency> hashAndFileNameToDep = new HashMap<>(); Connection conn = null; ResultSet rs = null; PreparedStatement stmnt = null; try { conn = this.dbOperator.getDataSource().getConnection(); if (conn == null) { throw new SQLException("Null connection"); } <START> conn.setAutoCommit(false); <END> stmnt = conn.prepareStatement( String .format("SELECT file_name, file_sha1, validation_status FROM validated_dependencies " + "WHERE validation_key = ? AND (%s)", makeStrWithQuestionMarks(deps.size()))); stmnt.setString(1, validationKey); int index = 2; for (Dependency d : deps) { stmnt.setString(index++, d.getFileName()); stmnt.setString(index++, d.getSHA1()); hashAndFileNameToDep.put(d.getFileName() + d.getSHA1(), d); } rs = stmnt.executeQuery(); conn.commit(); while (rs.next()) { Dependency d = hashAndFileNameToDep.remove(rs.getString(1) + rs.getString(2)); FileValidationStatus v = FileValidationStatus.valueOf(rs.getInt(3)); depValidationStatuses.put(d, v); } hashAndFileNameToDep.values().stream() .forEach(d -> depValidationStatuses.put(d, FileValidationStatus.NEW)); } catch (final SQLException ex) { log.error("Transaction failed: ", ex); throw ex; } finally { DbUtils.closeQuietly(rs); DbUtils.closeQuietly(stmnt); DbUtils.closeQuietly(conn); } return depValidationStatuses; }</code><technical_language>Nit: autocommit change is needed this is a single read-only statement. (Ok if tested this, though)</technical_language>

Target:
public Map<Dependency, FileValidationStatus> getValidationStatuses(final Set<Dependency> deps, final String validationKey) throws SQLException { Map<Dependency, FileValidationStatus> depValidationStatuses = new HashMap<>(); if (deps.isEmpty()) { return depValidationStatuses; } Map<String, Dependency> hashAndFileNameToDep = new HashMap<>(); Connection conn = null; ResultSet rs = null; PreparedStatement stmnt = null; try { conn = this.dbOperator.getDataSource().getConnection(); if (conn == null) { throw new SQLException("Null connection"); } stmnt = conn.prepareStatement( String .format("SELECT file_name, file_sha1, validation_status FROM validated_dependencies " + "WHERE validation_key = ? AND (%s)", makeStrWithQuestionMarks(deps.size()))); stmnt.setString(1, validationKey); int index = 2; for (Dependency d : deps) { stmnt.setString(index++, d.getFileName()); stmnt.setString(index++, d.getSHA1()); hashAndFileNameToDep.put(d.getFileName() + d.getSHA1(), d); } rs = stmnt.executeQuery(); while (rs.next()) { Dependency d = hashAndFileNameToDep.remove(rs.getString(1) + rs.getString(2)); FileValidationStatus v = FileValidationStatus.valueOf(rs.getInt(3)); depValidationStatuses.put(d, v); } hashAndFileNameToDep.values().stream() .forEach(d -> depValidationStatuses.put(d, FileValidationStatus.NEW)); } catch (final SQLException ex) { log.error("Transaction failed: ", ex); throw ex; } finally { DbUtils.closeQuietly(conn, stmnt, rs); } return depValidationStatuses; }