Search in sources :

Example 1 with MapJpaUpdaterProvider

use of org.keycloak.models.map.storage.jpa.updater.MapJpaUpdaterProvider in project keycloak by keycloak.

the class JpaMapStorageProviderFactory method validateAndUpdateSchema.

public void validateAndUpdateSchema(KeycloakSession session, Class<?> modelType) {
    if (this.validatedModels.add(modelType)) {
        Connection connection = getConnection();
        try {
            if (logger.isDebugEnabled())
                printOperationalInfo(connection);
            MapJpaUpdaterProvider updater = session.getProvider(MapJpaUpdaterProvider.class);
            MapJpaUpdaterProvider.Status status = updater.validate(modelType, connection, config.get("schema"));
            if (!status.equals(VALID)) {
                update(modelType, connection, session);
            }
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (SQLException e) {
                    logger.warn("Can't close connection", e);
                }
            }
        }
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) MapJpaUpdaterProvider(org.keycloak.models.map.storage.jpa.updater.MapJpaUpdaterProvider)

Aggregations

Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 MapJpaUpdaterProvider (org.keycloak.models.map.storage.jpa.updater.MapJpaUpdaterProvider)1