I have the following enum definition:
create type task_status as enum ('ok', 'fail')
A table:
create table if not exists task
(
id uuid default gen_random_uuid() not null primary key,
status task_status,
...
);
And the following codegen config:
<generator>
<name>org.jooq.codegen.JavaGenerator</name>
<generate>
<fluentSetters>true</fluentSetters>
<daos>true</daos>
<springAnnotations>true</springAnnotations>
<springDao>true</springDao>
</generate>
<database>
<name>org.jooq.meta.postgres.PostgresDatabase</name>
<inputSchema>public</inputSchema>
<includes>task</includes>
<includeTables>true</includeTables>
<includeSystemTables>false</includeSystemTables>
<includeInvisibleColumns>false</includeInvisibleColumns>
<includeEmbeddables>true</includeEmbeddables>
<includeRoutines>false</includeRoutines>
<forcedTypes>
<forcedType>
<name>INSTANT</name>
<includeTypes>timestamptz</includeTypes>
</forcedType>
</forcedTypes>
</database>
<target>
...
</target>
</generator>
When I run codegen, I get:
public class Task implements Serializable {
private Object status;
...
}
While I found no direct answer on whether jOOQ can indeed generate a Java enum type from this column type, it sounds like it just works for others. I am aware that I can implement custom generators or use an enum converter, but I want to know if Java enums can be generated out-of-the-box and I'm just doing it wrong. I'm on jOOQ 3.17.13.
You didn't include the enum type in your code generation configuration:
<includes>task</includes>
Do this, instead:
<includes>task|task_status</includes>