Unable to bind a null value for UUID column with PostgreSQL [SPR-16669] #21210
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: backported
An issue that has been backported to maintenance branches
type: regression
A bug that is also a regression
Milestone
Rémi Aubel opened SPR-16669 and commented
PostgreSQL database defines the type UUID (this type does not exist in
java.sql.Types
).I want to use this kind of PreparedStatement:
And I want to bind a null value for
VAL
.In this specific case, PostgreSQL JDBC driver requires the data type to be specified. And since the UUID data type does not exist in
java.sql.Types
, we must specify the type name as well, by callingPreparedStatement.setNull(\_, java.sql.Types.OTHER, "uuid")
.With plain old java (
Connection
andPreparedStatement
), this works fine.Using
NamedParameterJdbcTemplate
(and providing the "data type" and "data type name" in aMapSqlParameterSource
), I'm not able to make it work.Under the hood,
StatementCreatorUtils.setNull(\_, \_, type, typeName)
delegates toPreparedStatement.setNull(\_, type)
(with no type name) when type isTypes.OTHER
.Shouldn't it call
PreparedStatement.setNull(_, type, typeName)
whentypeName
is provided (non null) instead?Affects: 4.3.14, 5.0.4
Issue Links:
Referenced from: commits 9a722b4, 5629fa2
Backported to: 4.3.15
The text was updated successfully, but these errors were encountered: