Java jOOQ subselect中的类型安全列

Java jOOQ subselect中的类型安全列,java,jooq,Java,Jooq,我有生成jOOQSelect对象的代码,我需要将其用作更复杂查询的一部分 类似这样的工作原理: Select<Record3<Long, Integer, BigDecimal>> s = getFromSomewhere(); Field<?>[] f = s.fields(); // use it in a sub-select Select<Record2<?,?>> x = DSL.select(f[0], f[1]).fro

我有生成jOOQ
Select
对象的代码,我需要将其用作更复杂查询的一部分

类似这样的工作原理:

Select<Record3<Long, Integer, BigDecimal>> s = getFromSomewhere();
Field<?>[] f = s.fields();

// use it in a sub-select
Select<Record2<?,?>> x = DSL.select(f[0], f[1]).from(s);
选择s=getfromwhere();
字段[]f=s.fields();
//在子选择中使用它

选择作为解决方案,您可以创建以下不安全但保证工作的帮助器API:

public static <T1, T2, T3> Row3<T1, T2, T3> row3(Select<Record3<T1, T2, T3>> select) {
    return (Row3) DSL.row(select.field(1), select.field(2), select.field(3));
}

我还将此注册为jOOQ 3.6.0:.的功能请求。

行类型似乎很有用,请参见,但我不知道如何从Select中构造行。
public static <T1, T2, T3> Row3<T1, T2, T3> row3(Select<Record3<T1, T2, T3>> select) {
    (Row3<T1, T2, T3>) select.fieldsRow();
}
Select<Record3<Long, Integer, BigDecimal>> s = getFromSomewhere();
Row3<Long, Integer, BigDecimal> row = row3(s);

// use it in a sub-select
Select<Record2<Long, Integer>> x = DSL.select(row.field1(), row.field2()).from(s);