I'm calling a Spring method from Kotlin and Spring provides 2 signatures, one that takes 2 args (the second being varargs) and one that takes 3 args.
I want to call the 3-arg method, but I can't figure out how to match the types - it keeps calling the 2-arg version with the varargs slurping the values.
Here are the method signatures (I want to call the first, but it keeps calling the second):
@Override
public int update(String sql, Object[] args, int[] argTypes) throws DataAccessException {
return update(sql, newArgTypePreparedStatementSetter(args, argTypes));
}
@Override
public int update(String sql, @Nullable Object... args) throws DataAccessException {
return update(sql, newArgPreparedStatementSetter(args));
}
Here is my Kotlin code:
var sql = "INSERT INTO \"$sourceTable\" ($insertList) VALUES ($valueList)"
val p: Array<Any?> = params.toTypedArray()
val c: Array<Int> = columnTypes.toTypedArray()
targetJdbcTemplate.update(sql, p, c)
Clearly, something is going wrong and Array does not map to Object[], because my debugger shows me that I am calling the second method here, not the first.
How can I make Kotlin understand which method I want? How do I map Array<Any?>
Array<Int>
to Object[]
and Int[]
so the compiler will understand?