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

问题描述 投票:2回答:1

我想使用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个字段吗?

java dsl jooq querydsl
1个回答
2
投票

insertInto方法可以接受任何你想要的字段(它有特定的重载,最多22个字段,还有一个更通用的vararg版本,可以接受23个或更多字段)。所以只要在你展示的例子中继续添加你的字段,应该就可以了。

© www.soinside.com 2019 - 2024. All rights reserved.