我在用jOOQ和PostgreSQL解析UUID数组时遇到问题。我有以下查询:
context
.select(Tables.T1.IDENTIFIER)
.select(PostgresDSL.array(context.select(Tables.T2.IDENTIFIER).from(Tables.T2).where(<omitted>)).as("_references"))
.from(Tables.T1)
.fetch();
这与以下表结构相对应:
t1(identifier uuid primary key)
t2(identifier uuid primary key, t1_identifier uuid foreign key t1(identifier))
执行此查询时,出现以下异常:
org.jooq.exception.DataTypeException: Cannot convert from e472b684-0b04-4799-a3e1-a31711a78182 (class org.postgresql.util.PGobject) to class java.util.UUID
at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:1166)
at org.jooq.tools.Convert$ConvertAll.from(Convert.java:1055)
at org.jooq.tools.Convert.convert0(Convert.java:321)
at org.jooq.tools.Convert.convert(Convert.java:313)
at org.jooq.tools.Convert.convert(Convert.java:385)
at org.jooq.impl.DefaultBinding$DefaultUUIDBinding.get0(DefaultBinding.java:3805)
at org.jooq.impl.DefaultBinding$DefaultUUIDBinding.get0(DefaultBinding.java:3752)
at org.jooq.impl.DefaultBinding$AbstractBinding.get(DefaultBinding.java:774)
at org.jooq.impl.DefaultBinding$DefaultArrayBinding.pgGetArray(DefaultBinding.java:1095)
at org.jooq.impl.DefaultBinding$DefaultArrayBinding.get0(DefaultBinding.java:1032)
at org.jooq.impl.DefaultBinding$DefaultArrayBinding.get0(DefaultBinding.java:911)
at org.jooq.impl.DefaultBinding$AbstractBinding.get(DefaultBinding.java:774)
at org.jooq.impl.CursorImpl$CursorIterator$CursorRecordInitialiser.setValue(CursorImpl.java:1771)
at org.jooq.impl.CursorImpl$CursorIterator$CursorRecordInitialiser.operate(CursorImpl.java:1740)
at org.jooq.impl.CursorImpl$CursorIterator$CursorRecordInitialiser.operate(CursorImpl.java:1705)
at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:125)
at org.jooq.impl.CursorImpl$CursorIterator.fetchNext(CursorImpl.java:1669)
at org.jooq.impl.CursorImpl$CursorIterator.hasNext(CursorImpl.java:1636)
at org.jooq.impl.CursorImpl.fetchNext(CursorImpl.java:408)
at org.jooq.impl.CursorImpl.fetch(CursorImpl.java:394)
at org.jooq.impl.CursorImpl.fetch(CursorImpl.java:301)
at org.jooq.impl.AbstractResultQuery.execute(AbstractResultQuery.java:297)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:350)
at org.jooq.impl.AbstractResultQuery.fetch(AbstractResultQuery.java:323)
at org.jooq.impl.SelectImpl.fetch(SelectImpl.java:2700)
我在做明显的错误吗?我认为当标识符的类型为integer
时,这种方法可以正常工作,但是当我切换到uuid
时,它开始失败。
我在PostgreSQL 11上使用jOOQ 3.11.9。