Search in sources :

Example 1 with SimpleJdbcCall

use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project ovirt-engine by oVirt.

the class AuditLogDaoImpl method getTimeToWaitForNextPmOp.

@Override
public int getTimeToWaitForNextPmOp(String vdsName, String event) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vds_name", vdsName).addValue("event", event).addValue("wait_for_sec", Config.getValue(ConfigValues.FenceQuietTimeBetweenOperationsInSec));
    Map<String, Object> dbResults = new SimpleJdbcCall(getJdbcTemplate()).withFunctionName("get_seconds_to_wait_before_pm_operation").execute(parameterSource);
    String resultKey = dbEngineDialect.getFunctionReturnKey();
    return (Integer) dbResults.getOrDefault(resultKey, 0);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SimpleJdbcCall(org.springframework.jdbc.core.simple.SimpleJdbcCall)

Example 2 with SimpleJdbcCall

use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project ovirt-engine by oVirt.

the class EntityDaoImpl method getEntityNameByIdAndType.

@Override
public String getEntityNameByIdAndType(Guid objectId, VdcObjectType vdcObjectType) {
    MapSqlParameterSource parameterSource = sqlParameterSourceProvider.get().addValue("entity_id", objectId).addValue("object_type", vdcObjectType.getValue());
    Map<String, Object> dbResults = new SimpleJdbcCall(jdbcTemplate).withFunctionName("fn_get_entity_name").execute(parameterSource);
    String resultKey = dbEngineDialect.getFunctionReturnKey();
    return dbResults.get(resultKey) != null ? dbResults.get(resultKey).toString() : null;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CustomMapSqlParameterSource(org.ovirt.engine.core.dal.dbbroker.CustomMapSqlParameterSource) SimpleJdbcCall(org.springframework.jdbc.core.simple.SimpleJdbcCall)

Example 3 with SimpleJdbcCall

use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project ovirt-engine by oVirt.

the class VdsStaticDaoImpl method save.

@Override
public void save(VdsStatic vds) {
    Guid id = vds.getId();
    if (Guid.isNullOrEmpty(id)) {
        id = Guid.newGuid();
        vds.setId(id);
    }
    new SimpleJdbcCall(getJdbcTemplate()).withProcedureName("InsertVdsStatic").execute(getInsertOrUpdateParams(vds));
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) SimpleJdbcCall(org.springframework.jdbc.core.simple.SimpleJdbcCall)

Example 4 with SimpleJdbcCall

use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project spring-integration by spring-projects.

the class StoredProcExecutorTests method mockTheOperationsCache.

private void mockTheOperationsCache(final StoredProcExecutor storedProcExecutor) {
    Object cache = TestUtils.getPropertyValue(storedProcExecutor, "guavaCacheWrapper.jdbcCallOperationsCache.localCache");
    new DirectFieldAccessor(cache).setPropertyValue("defaultLoader", new CacheLoader<String, SimpleJdbcCallOperations>() {

        @Override
        public SimpleJdbcCall load(String storedProcedureName) {
            return mock(SimpleJdbcCall.class);
        }
    });
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SimpleJdbcCallOperations(org.springframework.jdbc.core.simple.SimpleJdbcCallOperations) SimpleJdbcCall(org.springframework.jdbc.core.simple.SimpleJdbcCall)

Example 5 with SimpleJdbcCall

use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project spring-integration by spring-projects.

the class StoredProcExecutor method createSimpleJdbcCall.

private SimpleJdbcCall createSimpleJdbcCall(String storedProcedureName) {
    final SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(this.dataSource);
    if (this.isFunction) {
        simpleJdbcCall.withFunctionName(storedProcedureName);
    } else {
        simpleJdbcCall.withProcedureName(storedProcedureName);
    }
    if (this.ignoreColumnMetaData) {
        simpleJdbcCall.withoutProcedureColumnMetaDataAccess();
    }
    simpleJdbcCall.declareParameters(this.sqlParameters.toArray(new SqlParameter[this.sqlParameters.size()]));
    if (!this.returningResultSetRowMappers.isEmpty()) {
        for (Entry<String, RowMapper<?>> mapEntry : this.returningResultSetRowMappers.entrySet()) {
            simpleJdbcCall.returningResultSet(mapEntry.getKey(), mapEntry.getValue());
        }
    }
    if (this.returnValueRequired) {
        simpleJdbcCall.withReturnValue();
    }
    simpleJdbcCall.getJdbcTemplate().setSkipUndeclaredResults(this.skipUndeclaredResults);
    return simpleJdbcCall;
}
Also used : SqlParameter(org.springframework.jdbc.core.SqlParameter) SimpleJdbcCall(org.springframework.jdbc.core.simple.SimpleJdbcCall) RowMapper(org.springframework.jdbc.core.RowMapper)

Aggregations

SimpleJdbcCall (org.springframework.jdbc.core.simple.SimpleJdbcCall)11 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)5 HashMap (java.util.HashMap)2 CustomMapSqlParameterSource (org.ovirt.engine.core.dal.dbbroker.CustomMapSqlParameterSource)2 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DataSource (javax.sql.DataSource)1 Guid (org.ovirt.engine.core.compat.Guid)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 JdbcOperations (org.springframework.jdbc.core.JdbcOperations)1 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)1 RowMapper (org.springframework.jdbc.core.RowMapper)1 SqlParameter (org.springframework.jdbc.core.SqlParameter)1 NamedParameterJdbcOperations (org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations)1 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)1 SimpleJdbcCallOperations (org.springframework.jdbc.core.simple.SimpleJdbcCallOperations)1 SimpleJdbcInsert (org.springframework.jdbc.core.simple.SimpleJdbcInsert)1 SimpleJdbcInsertOperations (org.springframework.jdbc.core.simple.SimpleJdbcInsertOperations)1