Java 类org.springframework.jdbc.core.namedparam.EmptySqlParameterSource 实例源码

项目:Camel    文件:ElsqlEndpoint.java   
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    SqlProcessingStrategy proStrategy = new ElsqlSqlProcessingStrategy(elSql);
    SqlPrepareStatementStrategy preStategy = new ElsqlSqlPrepareStatementStrategy();

    final SqlParameterSource param = new EmptySqlParameterSource();
    final String sql = elSql.getSql(elsqlName, new SpringSqlParams(param));
    LOG.debug("ElsqlConsumer @{} using sql: {}", elsqlName, sql);

    ElsqlConsumer consumer = new ElsqlConsumer(this, processor, namedJdbcTemplate, sql, param, preStategy, proStrategy);
    consumer.setMaxMessagesPerPoll(getMaxMessagesPerPoll());
    consumer.setOnConsume(getOnConsume());
    consumer.setOnConsumeFailed(getOnConsumeFailed());
    consumer.setOnConsumeBatchComplete(getOnConsumeBatchComplete());
    consumer.setBreakBatchOnConsumeFail(isBreakBatchOnConsumeFail());
    consumer.setExpectedUpdateCount(getExpectedUpdateCount());
    consumer.setUseIterator(isUseIterator());
    consumer.setRouteEmptyResultSet(isRouteEmptyResultSet());
    configureConsumer(consumer);
    return consumer;
}
项目:Camel    文件:ElsqlSqlProcessingStrategy.java   
@Override
public int commitBatchComplete(DefaultSqlEndpoint endpoint, NamedParameterJdbcTemplate namedJdbcTemplate,
                        SqlParameterSource parameterSource, String query) throws Exception {

    final SqlParameterSource param = new EmptySqlParameterSource();
    final String sql = elSql.getSql(query, new SpringSqlParams(param));
    LOG.debug("commitBatchComplete @{} using sql: {}", query, sql);

    return namedJdbcTemplate.execute(sql, param, new PreparedStatementCallback<Integer>() {
        @Override
        public Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
            ps.execute();

            int updateCount = ps.getUpdateCount();
            if (LOG.isTraceEnabled()) {
                LOG.trace("Update count {}", updateCount);
            }
            return updateCount;
        }
    });
}
项目:npjt-extra    文件:QueryType.java   
private static SqlParameterSource extractParameters(Method m, Object[] args, Collection<ParameterConverter> parameterConverters) {

        Annotation[][] parameterAnnotations = m.getParameterAnnotations();
        if (parameterAnnotations == null || parameterAnnotations.length == 0) {
            return new EmptySqlParameterSource();
        }

        MapSqlParameterSource ps = new MapSqlParameterSource();
        Class<?>[] parameterTypes = m.getParameterTypes();
        for (int i = 0; i < args.length; i++) {
            String name = parameterName(parameterAnnotations[i]);
            if (name != null) {
                Object arg = args[i];
                Class<?> parameterType = parameterTypes[i];

                boolean hasAccepted = false;
                for (ParameterConverter parameterConverter : parameterConverters) {
                    if (parameterConverter.accept(parameterType, parameterAnnotations[i])) {
                        hasAccepted = true;
                        parameterConverter.processParameter(name, arg, parameterType, ps);
                        break;
                    }
                }

                if (!hasAccepted) {
                    throw new IllegalStateException("Was not able to find a ParameterConverter able to process object: " + arg + " with class " + parameterType);
                }
            }
        }

        return ps;
    }
项目:lavagna    文件:ProjectServiceTest.java   
@Before
public void prepare() {
    jdbc.update("DELETE FROM LA_PROJECT_ROLE_PERMISSION", new EmptySqlParameterSource());
    jdbc.update("DELETE FROM LA_PROJECT_ROLE", new EmptySqlParameterSource());
    jdbc.update("DELETE FROM LA_CARD_LABEL_VALUE", new EmptySqlParameterSource());
    jdbc.update("DELETE FROM LA_CARD_LABEL_LIST_VALUE", new EmptySqlParameterSource());
    jdbc.update("DELETE FROM LA_CARD_LABEL", new EmptySqlParameterSource());
    jdbc.update("DELETE FROM LA_BOARD_COLUMN_DEFINITION", new EmptySqlParameterSource());
    jdbc.update("DELETE FROM LA_PROJECT", new EmptySqlParameterSource());
}
项目:alf.io    文件:DataMigrator.java   
void migratePluginConfig(Event event) {
    pluginConfigurationRepository.loadByEventId(-1).forEach(p -> {
        MapSqlParameterSource source = new MapSqlParameterSource("pluginId", p.getPluginId())
            .addValue("eventId", event.getId())
            .addValue("confName", p.getOptionName())
            .addValue("confValue", p.getValue())
            .addValue("description", p.getDescription())
            .addValue("confType", p.getComponentType().name());
        jdbc.update("insert into plugin_configuration(plugin_id, event_id, conf_name, conf_value, conf_description, conf_type) values(:pluginId, :eventId, :confName, :confValue, :description, :confType)", source);
    });
    jdbc.update("update plugin_configuration set event_id = -2 where event_id = -1", new EmptySqlParameterSource());
}
项目:alf.io    文件:DataMigrator.java   
void fillReservationsLanguage() {
    transactionTemplate.execute(s -> {
        jdbc.queryForList("select id from tickets_reservation where user_language is null", new EmptySqlParameterSource(), String.class)
                .forEach(id -> {
                    MapSqlParameterSource param = new MapSqlParameterSource("reservationId", id);
                    String language = optionally(() -> jdbc.queryForObject("select user_language from ticket where tickets_reservation_id = :reservationId limit 1", param, String.class)).orElse("en");
                    jdbc.update("update tickets_reservation set user_language = :userLanguage where id = :reservationId", param.addValue("userLanguage", language));
                });
        return null;
    });
}
项目:lavagna    文件:ConfigurationRepositoryTest.java   
@Before
public void prepare() {
    jdbc.update("DELETE FROM LA_CONF", new EmptySqlParameterSource());
}
项目:alf.io    文件:VacuumQuartzTables.java   
default void vacuumQuartzTables() {
    NamedParameterJdbcTemplate template = getTemplate();
    quartzTables.forEach(name -> template.update("vacuum full " + name, new EmptySqlParameterSource()));
}