ChunfyTseng ChunfyTseng - 3 years ago 48
SQL Question

Jooq generates POJO missing comments

eg.

SQL:

CREATE TABLE `collect` (
`travel_id` int NOT NULL COMMENT 'travel id',
`description` varchar(64) COMMENT 'description',
`creat_time` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT 'creat time',
PRIMARY KEY (`travel_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='collect';


The resulting POJO is as follows.

/**
* collect
*/
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.9.2"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Collect implements Serializable {

private Integer travelId;
private String description;
private LocalDateTime creatTime;

...
}


The POJO I want should be like this.

eg:

private Integer travelId //trave_lId


or

/* trave_lId */
private Integer travelId


my code generator:

.withPojos(true)
.withDaos(true)
.withSpringAnnotations(true)
.withJavaTimeTypes(true)


the POJO field does not have a corresponding comment.
what should i do?

Answer Source

Currently (as of jOOQ 3.9 and 3.10), comments are only generated on tables and records, not on POJOs. That's a missing feature which should be implemented in a future jOOQ version. I've created a feature request for this: https://github.com/jOOQ/jOOQ/issues/6456

You can override the JavaGenerator class from jooq-codegen in order to generate those comments manually, e.g. by overriding JavaGenerator.generatePojo().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download