我使用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代码。
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, "");
编译器告诉我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, "");
编译器告诉我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>
我还在GitHub上创建了一个问题:https://github.com/jOOQ/jOOQ/issues/7684
答案 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中修复