@Test public void sqlParameterValueRegistersSqlType() throws Exception { MapSqlParameterSource msps = new MapSqlParameterSource("FOO", new SqlParameterValue(2, "Foo")); assertEquals("Correct SQL Type not registered", 2, msps.getSqlType("FOO")); MapSqlParameterSource msps2 = new MapSqlParameterSource(); msps2.addValues(msps.getValues()); assertEquals("Correct SQL Type not registered", 2, msps2.getSqlType("FOO")); }
public class CombinedSqlParameterSource extends AbstractSqlParameterSource { private MapSqlParameterSource mapSqlParameterSource = new MapSqlParameterSource(); private BeanPropertySqlParameterSource beanPropertySqlParameterSource; public CombinedSqlParameterSource(Object object) { this.beanPropertySqlParameterSource = new BeanPropertySqlParameterSource(object); } public void addValue(String paramName, Object value) { mapSqlParameterSource.addValue(paramName, value); } @Override public boolean hasValue(String paramName) { return beanPropertySqlParameterSource.hasValue(paramName) || mapSqlParameterSource.hasValue(paramName); } @Override public Object getValue(String paramName) { return beanPropertySqlParameterSource.hasValue(paramName) ? beanPropertySqlParameterSource.getValue(paramName) : mapSqlParameterSource.getValue(paramName); } @Override public int getSqlType(String paramName) { return beanPropertySqlParameterSource.hasValue(paramName) ? beanPropertySqlParameterSource.getSqlType(paramName) : mapSqlParameterSource.getSqlType(paramName); } }