Hi,
I have a SQL result set that includes a varchar array as one of the
columns. I'm mapping over the Result<Record> returned by fetch() and
manually populating a pojo but I'm having trouble populating the String[]
array field of the pojo.
d.fetch("select array_agg(some_field) as theArray from sometable group by
some_field")
.stream()
.map(r -> {
SalesTouchPoint stp = new SalesTouchPoint();
stp.setAudience(r.getValue("people", Integer.class));
stp.setEpc(r.getValue("epc", Double.class));
stp.setTouchPoints(r.getValue("theArray", String[].class
));
return stp;
})
.collect(Collectors.toList());
As you can see from the above code I'm using Record.getValue (or
Record.get) to access the column "theArray" from the result set. I'm
getting a class cast exception:
Caused by: org.jooq.exception.DataTypeException: Cannot convert from [Ljava.
lang.String;@5a6782c3 (class java.lang.String) to class [Ljava.lang.String;
at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:1118) ~[na:na]
at org.jooq.tools.Convert$ConvertAll.from(Convert.java:1007) ~[na:na]
at org.jooq.tools.Convert.convert0(Convert.java:316) ~[na:na]
at org.jooq.tools.Convert.convert(Convert.java:308) ~[na:na]
at org.jooq.tools.Convert.convert(Convert.java:380) ~[na:na]
at org.jooq.impl.AbstractRecord.get(AbstractRecord.java:260) ~[na:na]
at org.jooq.impl.AbstractRecord.getValue(AbstractRecord.java:1222) ~[na:na]
Everything I've read in the docs suggests that JOOQ handles SQL array types
just fine. What am I doing wrong?
--
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.