由于多个Java错误,无法编译自动生成的JOOQ代码

时间:2018-07-24 08:35:49

标签: java postgresql jdbc jooq

我使用java --add-modules java.xml.bind -classpath jooq-3.11.3.jar;jooq-meta-3.11.3.jar;jooq-codegen-3.11.3.jar;postgresql-42.2.4.jar;. org.jooq.codegen.GenerationTool jooq.xml为我的PostgreSQL 10 USER表自动生成了JOOQ代码。

pgadmin4_2018-07-24_08-08-49

codegen工具成功完成,但是我的程序无法编译,因为自动生成的代码中存在多个Java语法错误。

一些例子:

PgClass.java

/**
* @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using <deprecationOnUnknownTypes/> in your code generator configuration.
*/
@java.lang.Deprecated
public final TableField<PgClassRecord, Object> RELPARTBOUND = createField("relpartbound", , this, "");

idea64_2018-07-24_08-12-48

编译器告诉我java: illigal start of expression

PgIndex.java:

/**
* The column <code>pg_catalog.pg_index.indoption</code>.
*/
public final TableField<PgIndexRecord, Object[]> INDOPTION = createField("indoption", .getArrayDataType(), this, "");

idea64_2018-07-24_08-15-31

编译器告诉我java: as of release 8, 'this' is allowed as the parameter name for the receiver type only, which has to be the first parameter

编辑:

jooq.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
  <jdbc>
    <driver>org.postgresql.Driver</driver>
    <url>jdbc:postgresql://localhost:5432/timecoder-api-dev</url>
    <user>postgres</user>
    <password></password>
  </jdbc>

  <generator>
    <database>
      <name>org.jooq.meta.postgres.PostgresDatabase</name>
      <includes>.*</includes>
    </database>
    <target>
      <packageName>persistence.database.generated</packageName>
      <directory>K:\Data\Dev\Git\timecoder-api\src</directory>
    </target>
  </generator>
</configuration>
  • jOOQ:3.11.3
  • Java:1.8.0_181
  • 数据库(包括供应商):PostgreSQL 10
  • 操作系统:Windows 10

我还在GitHub上创建了一个问题:https://github.com/jOOQ/jOOQ/issues/7684

2 个答案:

答案 0 :(得分:3)

我的数据库表位于Postgres模式“ public”中。 我忘记将<inputSchema>public</inputSchema>添加到我的jooq.xml中。现在工作正常:)

jooq.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
  <jdbc>
    <driver>org.postgresql.Driver</driver>
    <url>jdbc:postgresql://localhost:5432/timecoder-api-dev</url>
    <user>postgres</user>
    <password></password>
  </jdbc>

  <generator>
    <database>
      <name>org.jooq.meta.postgres.PostgresDatabase</name>
      <inputSchema>public</inputSchema>
      <includes>.*</includes>
    </database>
    <target>
      <packageName>persistence.database.generated</packageName>
      <directory>K:\Data\Dev\Git\timecoder-api\src</directory>
    </target>
  </generator>
</configuration>

答案 1 :(得分:1)

感谢您的举报。这是代码生成器中的错误:https://github.com/jOOQ/jOOQ/issues/7692

它将在jOOQ 3.12.0和3.11.4中修复