使用jOOQ从现有记录中选择

时间:2019-10-22 08:32:47

标签: jooq

jOOQ是否有可能在不丢失元信息的情况下从现有VALUES()创建Record表达式?

类似的东西:

    List<ExampleEntityRecord> records = ...

    select()
        .from(values(/* records */))
        .where(EXAMPLE_ENTITY.EXAMPLE_FIELD.eq("some value"))

当前我正在使用values(*records.map { it.valuesRow() }.toTypedArray())。但是结果是Table<RecordN</* ... */>>,其中没有有关字段的元信息。

1 个答案:

答案 0 :(得分:0)

您可以使用DSL.table(Result<R>)DSL.table(R...)便捷方法,这些方法在生成的<R extends Record>类型中保持Table<R>类型:

ExampleEntityRecord[] records = ...

select()
    .from(table(records).as(EXAMPLE_ENTITY))
    .where(EXAMPLE_ENTITY.EXAMPLE_FIELD.eq("some value"))

请注意,不幸的是,接受Collection<?>的重载功能稍有不同。