Hello.
I tried another version of that test:
test=> \d testarray
Table "public.testarray"
┌────────┬───────────┬────────────────────────────────────────────────────────┐
│ Column │ Type │
Modifiers │
├────────┼───────────┼────────────────────────────────────────────────────────┤
│ id │ integer │ not null default
nextval('testarray_id_seq'::regclass) │
│ a │ integer[] │ not
null │
└────────┴───────────┴────────────────────────────────────────────────────────┘
Indexes:
"testarray_pkey" PRIMARY KEY, btree (id)
test=> \sf get_testarray
CREATE OR REPLACE FUNCTION public.get_testarray(id_p integer)
RETURNS SETOF testarray
LANGUAGE plpgsql
AS $function$
BEGIN
RETURN QUERY SELECT * FROM testarray WHERE id = id_p;
END;
$function$
Here is the code I run:
String sql = "SELECT * FROM get_testarray(?)";
Result<Record> result = create.fetch(sql, 1);
System.out.println("Result: ");
System.out.println(result);
List<TestarrayRecord> l = result.into(TestarrayRecord.class);
The array part makes the whole thing explode:
Result:
+----+-------+
| id|a |
+----+-------+
| 1|{1,2,3}|
+----+-------+
org.jooq.exception.MappingException: An error ocurred when mapping record
to class com.ovh.osp.sql.tables.records.TestarrayRecord
at
org.jooq.impl.DefaultRecordMapper$RecordToRecordMapper.map(DefaultRecordMapper.java:430)
at
org.jooq.impl.DefaultRecordMapper$RecordToRecordMapper.map(DefaultRecordMapper.java:418)
at org.jooq.impl.DefaultRecordMapper.map(DefaultRecordMapper.java:331)
at org.jooq.impl.ResultImpl.into(ResultImpl.java:1502)
at test.Test.main(Test.java:57)
Caused by: org.jooq.exception.MappingException: An error ocurred when
mapping record to +----+------+
| id|a |
+----+------+
| 1|{null}|
+----+------+
at
org.jooq.impl.AbstractRecord$TransferRecordState.operate(AbstractRecord.java:754)
at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:123)
at org.jooq.impl.AbstractRecord.intoRecord(AbstractRecord.java:701)
at
org.jooq.impl.DefaultRecordMapper$RecordToRecordMapper.map(DefaultRecordMapper.java:424)
... 4 more
Caused by: org.jooq.exception.DataTypeException: Cannot convert from
{1,2,3} (class org.postgresql.jdbc4.Jdbc4Array) to class
[Ljava.lang.Integer;
at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:873)
at org.jooq.tools.Convert$ConvertAll.from(Convert.java:811)
at org.jooq.tools.Convert.convert0(Convert.java:300)
at org.jooq.tools.Convert.convert(Convert.java:292)
at org.jooq.tools.Convert.convert(Convert.java:360)
at org.jooq.impl.DefaultDataType.convert(DefaultDataType.java:614)
at
org.jooq.impl.AbstractRecord$TransferRecordState.operate(AbstractRecord.java:732)
... 7 more
Am I doing it wrong?
Adrien.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.