public static final EmptySqlParameterSource INSTANCE = new EmptySqlParameterSource();
@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; } }); }
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; }