JOOQ 生成器:缺少名称

JOOQ generator: Missing name

我正在尝试使用 Postgres 和 Gradle 设置 JOOQ。

每当我 运行 生成任务时,我得到 ~ 20 Ambiguous type names:

Ambiguous type name : The object pg_catalog.generate_series generates a type one.dbtest.db.pg_catalog.tables.GenerateSeries which conflicts with the existing type one.dbtest.db.pg_catalog.tables.GenerateSeries on some operating systems. Use a custom generator strategy to disambiguate the types. Ambiguous type name : The object pg_catalog.generate_series generates a type one.dbtest.db.pg_catalog.tables.GenerateSeries which conflicts with the existing type one.dbtest.db.pg_catalog.tables.GenerateSeries on some operating systems. Use a custom generator strategy to disambiguate the types.

还有数百个:

Missing name : Object jsonb_exists_all holds a column without a name at position 2 Missing name : Object jsonb_exists_any holds a column without a name at position 1 Missing name : Object jsonb_exists_any holds a column without a name at position 2 Missing name : Object jsonb_ge holds a column without a name at position 1 Missing name : Object jsonb_ge holds a column without a name at position 2 Missing name
: Object jsonb_gt holds a column without a name at position 1 Missing name : Object jsonb_gt holds a column without a name at position 2 Missing name : Object jsonb_hash holds a column without a name at position 1 Missing name : Object jsonb_in holds a column without a name at position 1 Missing name
: Object jsonb_le holds a column without a name at position 1 Missing name : Object jsonb_le holds a column without a name at position 2 Missing name : Object jsonb_lt holds a column without a name at position 1 Missing name : Object jsonb_lt holds a column without a name at position 2 Missing name
: Object jsonb_ne holds a column without a name at position 1 Missing name : Object jsonb_ne holds a column without a name at position 2

我需要排除 pg* 类型吗?

生成任务取自 JOOQ 示例:

task generate << {
  def writer = new StringWriter()
  def xml = new groovy.xml.MarkupBuilder(writer)
    .configuration("xmlns": "http://www.jooq.org/xsd/jooq-codegen-3.7.0.xsd") {
    jdbc() {
      driver("org.postgresql.Driver")
      url("jdbc:postgresql://localhost/pagila")
      user("xxx")
      password("xxx")
    }
    generator() {
      database() {
        name { mkp.yield( 'org.jooq.util.postgres.PostgresDatabase' ) }
        exclude("pg.*")
      }
      generate() {}
      target() {
        packageName("one.dbtest.db")
        directory("src")
      }
    }
  }

  //println writer.toString()

  org.jooq.util.GenerationTool.main(
    javax.xml.bind.JAXB.unmarshal(
        new StringReader(writer.toString()),
        org.jooq.util.jaxb.Configuration.class
    )
  )
}

更新:DB 是来自 http://pgfoundry.org/projects/dbsamples

的 pagila

对于 Postgres,您还必须指定输入模式,因此它是:

generator() {
  database() {
    name { mkp.yield( 'org.jooq.util.postgres.PostgresDatabase' ) }
    inputSchema("public")
  }
[..]

如果您已在生成器中添加 <name>org.jooq.meta.postgres.PostgresDatabase</name>,请在 pom.xml 文件的 <database> 块中添加 <inputSchema>public</inputSchema>