You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sql types don't seem to propagate. I used a postgres backend (jdbc driver 9.3-1102-jdbc41) on a 9.3 backend. The table uses the inet type to store ip addresses.
This works in 4.0.6 while it doesn't seem to work in 4.1
MapSqlParameterSource paramSource = new MapSqlParameterSource().addValue("ip",e.getIp(),Types.OTHER,"inet");
jdbcTemplate.update("insert into addresses (ip) values (:ip)",paramSource);
I think we can close this.
I tested this on 4.0.6, Spring 4.0.6 worked.
4.0.7 - 4.1.6 resulted in an SQLException
4.1.7 - 5.0.0 (latest) worked
I traced it to org.springframework.jdbc.core.StatementCreatorUtils.setValue
there is a giant if/else if/else if/.../else branch there.
the last if else and the final else triggered the bug.
the correct behaviour is to execute in the final else and have prepared statement call setObject
this is for version < 4.1.7
the last else if was
else if (sqlType == SqlTypeValue.TYPE_UNKNOWN) {
and the type passed was OTHERS, the final else was executed
ps.setObject(paramIndex, inValue, sqlType);
Result: Success
4.1.7 - 4.1.6
else if (sqlType == SqlTypeValue.TYPE_UNKNOWN || sqlType == Types.OTHER) {
since sqlType == OTHER is true, it does not go to the final else clause
and setObject was not called, setString was called.
Result -> error
4.1.7 - 5.0.0
else if (sqlType == SqlTypeValue.TYPE_UNKNOWN || (sqlType == Types.OTHER &&
"Oracle".equals(ps.getConnection().getMetaData().getDatabaseProductName()))) {
Condition is false.
final else is called.
Code works.
Koen Serry opened SPR-12346 and commented
Sql types don't seem to propagate. I used a postgres backend (jdbc driver 9.3-1102-jdbc41) on a 9.3 backend. The table uses the inet type to store ip addresses.
This works in 4.0.6 while it doesn't seem to work in 4.1
Affects: 4.1.1
Issue Links:
The text was updated successfully, but these errors were encountered: