微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java-JOOQ生成器:缺少名称

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

每当我运行generate任务时,我都会得到20个模糊的类型名称

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开始的历史记录

解决方法:

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐