Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jooq custom binding registration in Java

I have a custom binding written to convert from custom type to Postgres json type. This part of the documentation mentions how to register using xml but I'm using Java. I have tried to search to find how to do that but in vain.

Any help is appreciated.

like image 791
singularity Avatar asked Oct 16 '25 17:10

singularity


1 Answers

If by "I'm using Java", you mean using programmatic code generator configuration using Java:

There's a manual section about programmatic code generator configuration here:

http://www.jooq.org/doc/latest/manual/code-generation/codegen-programmatic

Essentially, all XML elements also exist as Java types, which are generated with XJC from the code generation configuration XSD, so all XML configuration maps 1:1 to Java configuration, including that for data type bindings (via ForcedType objects).

If by "I'm using Java", you mean you don't use the code generator and want to create a binding:

The code generator doesn't do anything magic. Everything it does, you can do manually as well. You can easily call:

DataType<MyJsonType> jsonType = 
    SQLDataType.VARCHAR.asConvertedDataType(new MyJsonBinding());
Field<MyJsonType> jsonField = field(name("my_table", "my_column"), jsonType);

Of course, using the code generator instead will greatly help...

like image 108
Lukas Eder Avatar answered Oct 18 '25 08:10

Lukas Eder