Hello!
I am using jooq 3.1.0 and MySQL 5.5.31, and the generated code for my
database has en compilation error after I introduced an ENUM type attribute
in one of the database tables.
The table is:
delimiter $$
> CREATE TABLE `user` (
> `id` int(11) NOT NULL AUTO_INCREMENT,
> `username` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
> `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
> `birthday` date NOT NULL,
> `gender` tinyint(1) NOT NULL,
> `phone` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
> `role` enum('common_user','company_user','admin') COLLATE
> utf8_unicode_ci NOT NULL DEFAULT 'common_user', <-- This is the
> ENUM-typed column!
> PRIMARY KEY (`id`),
> UNIQUE KEY `username_UNIQUE` (`username`),
> UNIQUE KEY `phone_UNIQUE` (`phone`)
> ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8
> COLLATE=utf8_unicode_ci$$
and I have compilation error with this generated file:
/**
* This class is generated by jOOQ
*/
package com.comoyo.okapi.backend.db.jooq.enums;
/**
* This class is generated by jOOQ.
*/
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public enum UserRole implements org.jooq.EnumType {
common_user("common_user"),
company_user("company_user"),
admin("admin"),
;
private final java.lang.String literal;
private UserRole(java.lang.String literal) {
this.literal = literal;
}
/**
* {@inheritDoc}
*/
*@Override*
public org.jooq.Schema getSchema() {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.String getName() {
return "user_role";
}
/**
* {@inheritDoc}
*/
@Override
public java.lang.String getLiteral() {
return literal;
}
}
The compilation error occurs at the red part of the above code. The error
is: "method does not override or implement a method from a supertype"
After searching in the previous posts, I find that this bug (if it is a
bug) is introduced in the fix of issue #2135:
https://github.com/jOOQ/jOOQ/issues/2135 The fix is here:
https://github.com/jOOQ/jOOQ/commit/591afd7fcb3ad1796ed9b90c8331d5a46289af47
For your reference, this is my configuration for the jooq generator:
<generator>
<!-- The default code generator. You can override
this one, to generate your own code style Defaults to
org.jooq.util.DefaultGenerator -->
<name>org.jooq.util.DefaultGenerator</name>
<database>
<!-- The database type. The format here is:
org.util.[database].[database]Database -->
<name>org.jooq.util.mysql.MySQLDatabase</name>
<!-- The database schema (or in the absence of
schema support, in your RDBMS this can be the owner, user, database
name)
to be generated -->
<inputSchema>okapi</inputSchema>
<!-- All elements that are generated from your
schema (A Java regular expression. Use the pipe to separate several
expressions)
Watch out for case-sensitivity. Depending on your database, this
might be
important! -->
<includes>.*</includes>
<!-- All elements that are excluded from your
schema (A Java regular expression. Use the pipe to separate several
expressions).
Excludes match before includes -->
<excludes></excludes>
</database>
<target>
<!-- The destination package of your generated
classes (within the destination directory) -->
<packageName>com.example</packageName>
<!-- The destination directory of your generated
classes -->
<directory>src/main/java</directory>
</target>
<generate>
<!-- Primary key / foreign key relations should
be generated and used. This is a prerequisite for various advanced
features.
Defaults to true -->
<relations>true</relations>
<!-- Generate deprecated code for backwards compatibility
Defaults to true -->
<deprecated>true</deprecated>
<!-- Generate instance fields in your tables,
as opposed to static fields. This simplifies aliasing. Defaults to
true -->
<instanceFields>true</instanceFields>
<!-- Generate the javax.annotation.Generated
annotation to indicate jOOQ version used for source code. Defaults
to true -->
<generatedAnnotation>false</generatedAnnotation>
<!-- Generate jOOQ Record classes for type-safe
querying. You can turn this off, if you don't need "active records"
for CRUD
Defaults to true -->
<records>true</records>
<!-- Generate POJOs in addition to Record classes
for usage of the ResultQuery.fetchInto(Class) API Defaults to false
-->
<pojos>true</pojos>
<!-- Generate immutable POJOs for usage of the
ResultQuery.fetchInto(Class) API This overrides any value set in
<pojos/>
Defaults to false -->
<immutablePojos>false</immutablePojos>
<!-- Generate interfaces that will be implemented
by records and/or pojos. You can also use these interfaces in
Record.into(Class<?>)
and similar methods, to let jOOQ return proxy objects for them.
Defaults
to false -->
<interfaces>false</interfaces>
<!-- Generate DAOs in addition to POJO classes
Defaults to false -->
<daos>true</daos>
<!-- Annotate POJOs and Records with JPA annotations
for increased compatibility and better integration with
JPA/Hibernate, etc
Defaults to false -->
<jpaAnnotations>false</jpaAnnotations>
<!-- Annotate POJOs and Records with JSR-303
validation annotations Defaults to false -->
<validationAnnotations>false</validationAnnotations>
<!-- Allow to turn off the generation of global
object references, which include - Tables.java - Sequences.java -
UDTs.java
Turning off the generation of the above files may be necessary for
very large
schemas, which exceed the amount of allowed constants in a class's
constant
pool (64k) or, whose static initialiser would exceed 64k of byte
code Defaults
to true -->
</generate>
</generator>
I am new to jooq so I am not sure if it is a bug or it is because I did
something wrong.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.