spring-data-relational
spring-data-relational copied to clipboard
GH-2188 - Preserve JDBCType.OTHER for custom converters in string-based queries
This PR addresses GH-2188 (Converters with JDBCType.OTHER broken).
Summary
Custom converters that return JdbcValue with JDBCType.OTHER stopped working correctly for string-based queries.
StringBasedJdbcQuery treated JDBCType.OTHER as a special case and did not register its SQL type when binding parameters, so the JDBC driver did not see Types.OTHER anymore.
Changes
- Update
StringBasedJdbcQuery.bindParameters(…)to register the SQL type for all non-nullSQLTypevalues, includingJDBCType.OTHER, and only fall back to the type-lessaddValue(name, value)overload when the JDBC type is actuallynull. - Add a regression test to
StringBasedJdbcQueryUnitTeststhat:- uses a custom
@WritingConverterreturningJdbcValue.of(…, JDBCType.OTHER), - executes a string-based query method,
- and asserts that the resulting
SqlParameterSourceexposesTypes.OTHERfor the bound parameter.
- uses a custom
This restores the behavior for PostgreSQL enum/custom types and other use cases that rely on JDBCType.OTHER in custom converters.
Closes #2188