/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @param sqlType the SQL type of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, @Nullable Object value, int sqlType) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); registerSqlType(paramName, sqlType); return this; }
/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, @Nullable Object value) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); if (value instanceof SqlParameterValue) { registerSqlType(paramName, ((SqlParameterValue) value).getSqlType()); } return this; }
/** * Add a Map of parameters to this parameter source. * @param values a Map holding existing parameter values (can be {@code null}) * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValues(@Nullable Map<String, ?> values) { if (values != null) { values.forEach((key, value) -> { this.values.put(key, value); if (value instanceof SqlParameterValue) { registerSqlType(key, ((SqlParameterValue) value).getSqlType()); } }); } return this; }
/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @param sqlType the SQL type of the parameter * @param typeName the type name of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, @Nullable Object value, int sqlType, String typeName) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); registerSqlType(paramName, sqlType); registerTypeName(paramName, typeName); return this; }
map.addValue("customersince", new Date()); map.addValue("version", 0); map.registerSqlType("customersince", Types.DATE); map.registerSqlType("version", Types.NUMERIC);
/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @param sqlType the SQL type of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, Object value, int sqlType) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); registerSqlType(paramName, sqlType); return this; }
/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @param sqlType the SQL type of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, @Nullable Object value, int sqlType) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); registerSqlType(paramName, sqlType); return this; }
/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @param sqlType the SQL type of the parameter * @param typeName the type name of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, Object value, int sqlType, String typeName) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); registerSqlType(paramName, sqlType); registerTypeName(paramName, typeName); return this; }
/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, Object value) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); if (value instanceof SqlParameterValue) { registerSqlType(paramName, ((SqlParameterValue) value).getSqlType()); } return this; }
/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, @Nullable Object value) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); if (value instanceof SqlParameterValue) { registerSqlType(paramName, ((SqlParameterValue) value).getSqlType()); } return this; }
/** * Add a parameter to this parameter source. * @param paramName the name of the parameter * @param value the value of the parameter * @param sqlType the SQL type of the parameter * @param typeName the type name of the parameter * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValue(String paramName, @Nullable Object value, int sqlType, String typeName) { Assert.notNull(paramName, "Parameter name must not be null"); this.values.put(paramName, value); registerSqlType(paramName, sqlType); registerTypeName(paramName, typeName); return this; }
/** * Add a Map of parameters to this parameter source. * @param values a Map holding existing parameter values (can be {@code null}) * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValues(Map<String, ?> values) { if (values != null) { for (Map.Entry<String, ?> entry : values.entrySet()) { this.values.put(entry.getKey(), entry.getValue()); if (entry.getValue() instanceof SqlParameterValue) { SqlParameterValue value = (SqlParameterValue) entry.getValue(); registerSqlType(entry.getKey(), value.getSqlType()); } } } return this; }
/** * Add a Map of parameters to this parameter source. * @param values a Map holding existing parameter values (can be {@code null}) * @return a reference to this parameter source, * so it's possible to chain several calls together */ public MapSqlParameterSource addValues(@Nullable Map<String, ?> values) { if (values != null) { values.forEach((key, value) -> { this.values.put(key, value); if (value instanceof SqlParameterValue) { registerSqlType(key, ((SqlParameterValue) value).getSqlType()); } }); } return this; }