Entities annotated with @Type(type = "jsonb") are discarded from jooq code generator

341 views Asked by At

If i annotate an entity with @Type(type = "jsonb") from

     <dependency>
        <groupId>com.vladmihalcea</groupId>
        <artifactId>hibernate-types-52</artifactId>
     </dependency>
   

the entity is excluded from the jOOQ code generation process (no table, records...).

Is there a solution that does not involve excluding the annotation? (https://www.jooq.org/doc/latest/manual/code-generation/custom-data-type-bindings/ ??! )

Thanks

1

There are 1 answers

0
Lukas Eder On

As mentioned in the related github issue #10723, this seems to be a limitation of how the JPADatabase currently works (in jOOQ 3.13, 3.14). It uses Hibernate to create your schema in an in-memory H2 database prior to reverse engineering that.

H2 doesn't support the JSONB data type, although the JSON type is supported. This means that your com.vladmihalcea.hibernate.type.json.JsonBinaryType cannot be used with this combination of features. You have a few options:

  • Don't use the JPADatabase, which is always a source of limitations due to the above reasons. Using an actual PostgreSQL connection for jOOQ code generation will work better if you're planning on using vendor specific features. You could even run your code generation off a testcontainers managed database, as is requested in feature request #6551, or shown in this example.
  • Use the JSON type instead, which seems to work. This would be a pity, of course, as PostgreSQL offers better performance with JSONB than with JSON, but it might be a viable workaround in your case.