I have a spring boot app with jooq as DAO.
First, I create a enum type role in postgresql (code)
create type role as enum ('admin', 'user');
create table inventory_membership (
user_id integer references user_profile (id),
inventory_id integer references inventory (id),
role role not null default 'user',
primary key (user_id, inventory_id)
)
Then, as I want to use the java enum role in my app, I configure my pom.xml with below (code):
<forcedTypes>
<forcedType>
<userType>com.ocdexperience.sbjooqflywaypoc.db.enums.Role</userType>
<enumConverter>true</enumConverter>
<includeExpression>role</includeExpression>
<includeTypes>.*</includeTypes>
</forcedType>
</forcedTypes>
Then I run codegen. Here is the InventoryMembership pojo. Note the Role role field.
public class InventoryMembership implements Serializable {
private static final long serialVersionUID = 632233638;
private Integer userId;
private Integer inventoryId;
private Role role;
...
}
However, if I run codegen without the <forcedTypes> block in pom.xml, I will get Object role instead, which is not good.
public class InventoryMembership implements Serializable {
private static final long serialVersionUID = -1258093557;
private Integer userId;
private Integer inventoryId;
private Object role;
...
}
Seems <forceTypes> block is a must. However, in this example, there is no <forceTypes> block in pom.xml, but the generated code uses the generated enum automatically, instead of using Object.
Is that only due to the different jooq version? My project uses 3.12.1 vs the example project uses 3.13. Or is it because something else?
Thank you. My project is ready for up and run in https://github.com/ocdexperience/sbjooqflyway-poc.