Hi,
I've figured out that when generating code using the programmatic configuration enums are not properly generated/mapped. Since I'm not sure if I'm doing it wrong, I post in this group rather than creating a github issue ^^
This is the code-generator:
public class Main {
public static void main(String[] args) {
Configuration configuration = createGeneratorConfig();
try {
GenerationTool.generate(configuration);
} catch (Exception e) {
e.printStackTrace();
}
}
private static Configuration createGeneratorConfig(){
Jdbc jdbcConfig = new Jdbc();
jdbcConfig.setDriver("com.mysql.jdbc.Driver");
jdbcConfig.setUrl("jdbc:mysql://127.0.0.1:3306/");
jdbcConfig.setUser("user");
jdbcConfig.setPassword("password");
Configuration configuration = new Configuration();
Database databaseConfig = new Database();
databaseConfig.setName(MySQLDatabase.class.getName());
databaseConfig.setInputSchema("test");
databaseConfig.setOutputSchemaToDefault(true);
databaseConfig.setIncludes("example");
Target targetConfig = new Target();
targetConfig.setPackageName("generated");
targetConfig.setDirectory("src/main/java");
Generate generateConfig = new Generate();
generateConfig.withInterfaces(true);
Strategy strategy = new Strategy();
strategy.setName(DefaultGeneratorStrategy.class.getName());
Generator generatorConfig = new Generator();
generatorConfig.setName(JavaGenerator.class.getName());
generatorConfig.setDatabase(databaseConfig);
generatorConfig.setTarget(targetConfig);
generatorConfig.setGenerate(generateConfig);
generatorConfig.setStrategy(strategy);
configuration.setGenerator(generatorConfig);
configuration.setJdbc(jdbcConfig);
return configuration;
}
}
This is how the table looks like:
CREATE TABLE `example` (
`someId` int(11) NOT NULL AUTO_INCREMENT,
`someEnum` enum('FOO','BAR','BAZ') DEFAULT NULL,
PRIMARY KEY (`someId`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
And finally this is the generated interface:
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.9.2"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public interface IExample extends Serializable {
/**
* Setter for <code>example.someId</code>.
*/
public void setSomeid(Integer value);
/**
* Getter for <code>example.someId</code>.
*/
public Integer getSomeid();
/**
* Setter for <code>example.someEnum</code>.
*/
public void setSomeenum(String value);
/**
* Getter for <code>example.someEnum</code>.
*/
public String getSomeenum();
// -------------------------------------------------------------------------
// FROM and INTO
// -------------------------------------------------------------------------
/**
* Load data from another generated Record/POJO implementing the common interface IExample
*/
public void from(generated.tables.interfaces.IExample from);
/**
* Copy data into another generated Record/POJO implementing the common interface IExample
*/
public <E extends generated.tables.interfaces.IExample> E into(E into);
}
Obviously I've expected field someEnum to be an generated EnumType and not String. What am I doing wrong?
PS: generating code using the maven-generator works and I'm using jooq 3.9.2.