【问题标题】:How to convert data into Result<Record> data type in jooq如何在 jooq 中将数据转换为 Result<Record> 数据类型
【发布时间】:2021-12-10 19:53:27
【问题描述】:

我正在做一个大型项目,其中我要使用的功能,以 List> 的形式接受数据,然后将其发送到前端或转换为 csv。

我正在接收列表形式的数据,我想将数据从列表转换为列表>。怎么办?

public class Object {
  int x;
  string str;
  float f;
}

【问题讨论】:

标签: java jooq


【解决方案1】:

您可以像这样使用DSLContext.newResult()DSLContext.newRecord() 在内存中创建Result 值:

Field<Integer> x = ...;
Field<String> str = ...;
Field<Float> f = ...;

Result<Record3<Integer, String, Float>> r = ctx.newResult(x, str, f);
for (Object o : list)
    r.add(ctx.newRecord(x, str, f).values(o.x, o.str, o.f));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 2014-10-09
    • 2016-06-25
    • 1970-01-01
    相关资源
    最近更新 更多