This is not a proper MCVE, but it should be enough. If it's not, I'll do better.
Create a table with a field of type "integer array", like this:
CREATE TABLE public.test_table_1
(
column1 integer[] NOT NULL
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_1
OWNER to postgres;
In Kotlin, define this interface:
interface IThing : List<String>
Notice how this interface inherits from List<T>. This is important.
Here's an implementation:
class Thing(val items: List<String>) : IThing, List<String> by items
Here's a converter between Array<Int> and the offending interface.
class IntArrayIThingConverter : Converter<Array<Int>, IThing> {
override fun from(databaseObject: Array<Int>?): IThing? =
databaseObject?.let { Thing(it.map { it.toString() }) }
override fun to(userObject: IThing?): Array<Int>? =
userObject?.map { it.toInt() }?.toTypedArray()
override fun fromType(): Class<Array<Int>> =
Array<Int>::class.java
override fun toType(): Class<IThing> =
IThing::class.java
}
The converter is used to force the type:
forcedType {
userType = 'x.y.z.IThing'
converter = 'x.y.z.IntArrayIThingConverter'
includeExpression = '.*\\..*column1.*'
}
If you now fetch a row, like with
fun DSLContext.fetchTestTable_1() : List<TestTable_1Pojo> =
selectFrom(TEST_TABLE_1).fetchInto(TestTable_1Pojo::class.java)
This codein DefaultRecordMapper.java is executed:
// [#3082] Map nested collection types
if (value instanceof Collection && List.class.isAssignableFrom(mType)) {
Class componentType = (Class) ((ParameterizedType) method.getGenericParameterTypes()[0]).getActualTypeArguments()[0];
method.invoke(result, Convert.convert((Collection) value, componentType));
}
This expression:
((ParameterizedType) method.getGenericParameterTypes()[0]).
evaluates to the interface type IThing, which implements List but has no actual type arguments.
If List.class.isAssignableFrom(mType) is true, you should check the inheritance hierarchy of the type, to find the actual List type.
Please, let me know if this is enough.
Regards,
Maurizio.