I found BeanPropertySqlParameterSource useful for use but it still supports java 1.3 java types. Today its normal to use for temporal fields from java.time
package. But BeanPropertySqlParameterSource
know nothing how to handle that and no way to plug that functionality into.
@Override
public int getSqlType(String paramName) {
int sqlType = super.getSqlType(paramName);
if (sqlType != TYPE_UNKNOWN) {
return sqlType;
}
Class<?> propType = this.beanWrapper.getPropertyType(paramName);
return StatementCreatorUtils.javaTypeToSqlParameterType(propType);
}
this.beanWrapper
is private so extending BeanPropertySqlParameterSource
will give useless object and StatementCreatorUtils.javaTypeToSqlParameterType
stuck in old java.
Making BeanPropertySqlParameterSource.beanWrapper
protected will allow to override this class and manipulate with custom types of bean, including ones from java.time
.
Comment From: simonbasle
It looks like the necessary support for LocalTime
/LocalDate
/LocalDateTime
was added as part of gh-28778 a few month after this issue was created. That said, the aforementioned change didn't cover two additional types from java.time
: OffsetTime
(a TIME_WITH_TIMEZONE
) and OffsetDateTime
(a TIMESTAMP_WITH_TIMEZONE
).
In the light of this, I'm going to close this issue as declined
because we don't really need to address the initial ask (making this.beanWrapper
protected
).
I'm going to open a PR to add coverage for the two missing types mentioned above, though: https://github.com/spring-projects/spring-framework/pull/30123