Jooq Java CTE 渲染错误

Jooq Java CTE wrong render

我有从 DSL.values:

创建的 CTE
final RowN[] rowNS = tasksId
                .stream()
                .map(x -> DSL.row(x.toString()))
                .toArray(RowN[]::new);

        CommonTableExpression<Record1<String>> cte = DSL
                .name("cte")
                .fields("id")
                .as(DSL
                        .select(
                                DSL.field("id", String.class)
                        )
                        .from(
                                DSL.values(rowNS).as("temp", "id")
                        )
                );

然后我尝试使用它从数据库中获取所需的值

                dslContext
                        .with(
                                cte
                        )
                        .select(
                                DSL.field(TaskStateTable.taskId.getColumnName(), String.class),
                                DSL.field(TaskStateTable.state.getColumnName(), String.class)
                        )
                        .from(
                                DSL.table(tableNameProperties.getFullNameTableTaskState())
                        )
                        .join(
                                cte
                        )
                        .on(
                                DSL.field(tableNameProperties.getFullNameTableTaskState() + "." + TaskStateTable.taskId.getColumnName())
                                        .eq(cte.field("id"))
                        )
                        .fetchMap(
                                DSL.field(TaskStateTable.taskId.getColumnName(), String.class),
                                DSL.field(TaskStateTable.state.getColumnName(), String.class)
                        )

但我只有下一个错误

jOOQ; uncategorized SQLException for SQL [with cte(id) as (select id from ((select null id where 1 = 0) union all (select * from (values(cast(? as varchar))) temp)) temp) select task_id, state from rtm.task_state join cte on rtm.task_state.task_id = cte.id]

我想这是因为 (select * from (values(cast(? as varchar))

如何解决? 没有 cte 的其他方法也可以正常工作。

问题出在:

DSL.field("id", String.class)

“Id”需要用DSL.name()

包裹
DSL.field(DSL.name("id"), String.class)