use of org.flywaydb.core.internal.jdbc.RowMapper in project flyway by flyway.
the class JdbcTableSchemaHistory method refreshCache.
private void refreshCache() {
int maxCachedInstalledRank = cache.isEmpty() ? -1 : cache.getLast().getInstalledRank();
String query = database.getSelectStatement(table);
try {
cache.addAll(jdbcTemplate.query(query, new RowMapper<AppliedMigration>() {
public AppliedMigration mapRow(final ResultSet rs) throws SQLException {
// Construct a map of lower-cased column names to ordinals. This is useful for databases that
// upper-case them - eg Snowflake with QUOTED-IDENTIFIERS-IGNORE-CASE turned on
HashMap<String, Integer> columnOrdinalMap = constructColumnOrdinalMap(rs);
Integer checksum = rs.getInt(columnOrdinalMap.get("checksum"));
if (rs.wasNull()) {
checksum = null;
}
return new AppliedMigration(rs.getInt(columnOrdinalMap.get("installed_rank")), rs.getString(columnOrdinalMap.get("version")) != null ? MigrationVersion.fromVersion(rs.getString(columnOrdinalMap.get("version"))) : null, rs.getString(columnOrdinalMap.get("description")), MigrationType.fromString(rs.getString(columnOrdinalMap.get("type"))), rs.getString(columnOrdinalMap.get("script")), checksum, rs.getTimestamp(columnOrdinalMap.get("installed_on")), rs.getString(columnOrdinalMap.get("installed_by")), rs.getInt(columnOrdinalMap.get("execution_time")), rs.getBoolean(columnOrdinalMap.get("success")));
}
}, maxCachedInstalledRank));
} catch (SQLException e) {
throw new FlywaySqlException("Error while retrieving the list of applied migrations from Schema History table " + table, e);
}
}
Aggregations