java - 使用 jooq dsl 插入超过 22 个字段

标签 java dsl jooq querydsl

我想使用 dsl 上下文插入超过 22 个字段。


 val dslContext: DSLContext = DSL.using(
    DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres?user=postgres&password=postgres"),
    SQLDialect.POSTGRES,
    jooqSettings)


 dslContext
        .insertInto(
          table,
          table.field1,
          table.field2,
          table.field3,
          table.field4,
          table.field5,
          table.field6,
          table.field7,
          table.field8,
          table.field9,
          table.field10,
        )
        .values(
          fields(0),
          fields(1),
          fields(2),
          fields(3),
          fields(4),
          fields(5),
          fields(6),
          fields(7),
          fields(8),
          fields(9)
        )
        .execute()

我想插入超过 22 个字段,但构造函数最多允许 22 个字段。可以插入22个字段吗?

最佳答案

insertInto 方法可以接受任意数量的字段(它具有最多 22 个字段的特定重载和一个更通用的 vararg 版本,可以接受 23 个或更多字段)。因此,只需在您展示的示例中继续添加您的字段,它应该可以正常工作。

关于java - 使用 jooq dsl 插入超过 22 个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62327698/

相关文章:

java - JOOQ API getPrimaryKey() 对每个表返回 null?

sql - Scala SQL DSL(内部/外部)

Elasticsearch |匹配多个短语

groovy dsl - 中缀运算符可能吗?

java - 将 JOOQ 与 postgresql citext 结合使用

java - JOOQ 与 hibernate

java - 并行无锁升序 id 生成

java - Spring 数据 REST : How to retrieve many items using list of Ids in one single call?

java - 是否可以在 Java 中使用 SQOOP 从 MySQL 读取/写入 Hadoop 作业?

java - 将对象(double 类型)转换为 int