I followed the answer in Is it possible to write a data type Converter to handle postgres JSON columns? to implement the nodeObject converter.
Then I tried to use an updatable record to insert a record, I got "org.jooq.exception.SQLDialectNotSupportedException: Type class org.postgresql.util.PGobject is not supported in dialect POSTGRES" exception."
How can I solve this?
Following is my code:
TableRecord r = create.newRecord(TABLE);
ObjectNode node = JsonNodeFactory.instance.objectNode();
r.setValue(TABLE.JSON_FIELD, node, new JsonObjectConverter());
r.store();
Since jOOQ 3.5, you can register your own custom data type bindings to the code generator as is documented here:
http://www.jooq.org/doc/latest/manual/code-generation/custom-data-type-bindings
Unlike a
Converter
, aBinding
dictates how your data type is being handled at the JDBC level within jOOQ, without jOOQ knowing about your implementation. I.e., not only will you define how to convert between<T>
and<U>
types (T
= database type,U
= user type), but you will also be able to define how such types are:An example
Binding
for use with Jackson to produceJsonNode
types is given here:And the
Converter
that is used above can be seen here:You can now register the above binding via the code generator configuration: