From Kotlin, calling JdbcTemplate.batchUpdate with an array containing nulls is impossible because of a missing nullability annotation:
jdbcTemplate.batchUpdate(
"""
INSERT INTO "my_table" ("non_null", "can_be_null") VALUES (?, ?)
""",
listOf(
arrayOf<Any?>(
"non-null",
null,
)
)
)
Error:
None of the following candidates is applicable:
<SNIP>
vvvvvvvvv
fun batchUpdate(sql: String, batchArgs: (Mutable)List<Array<(out) Any>>): IntArray:
Argument type mismatch: actual type is 'List<Array<Any?>>', but '(Mutable)List<Array<(out) Any>>' was expected.
Proposed solution
Change to List<@Nullable Object[]> here:
|
@Override |
|
public int[] batchUpdate(String sql, List<Object[]> batchArgs) throws DataAccessException { |
|
return batchUpdate(sql, batchArgs, new int[0]); |
|
} |
|
|
|
@Override |
|
public int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes) throws DataAccessException { |
|
if (batchArgs.isEmpty()) { |
From Kotlin, calling JdbcTemplate.batchUpdate with an array containing nulls is impossible because of a missing nullability annotation:
Error:
Proposed solution
Change to
List<@Nullable Object[]>here:spring-framework/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java
Lines 1048 to 1055 in 1700fad