How to map json columns to String fields when generating Java objects

195 Views Asked by At

When Jooq generates Java objects, the json columns are mapped to org.jooq.JSON fields by default.

`keywords` json DEFAULT NULL COMMENT 'keywords',
private JSON keywords;

I want to map json columns to java.lang.String fields. How should I set up the xml configuration file?

Thanks.

The database I am using is MYSQL8.

1

There are 1 best solutions below

0
Lukas Eder On BEST ANSWER

You can use data type rewriting in the code generator, pretending those are VARCHAR columns. E.g.

<forcedType>
  <name>VARCHAR</name>
  <includeExpression>(?i:keywords)</includeExpression>
</forcedType>

Or even:

<forcedType>
  <name>VARCHAR</name>
  <includeTypes>(?i:json)</includeTypes>
</forcedType>

See the manual for all configuration options