I'm doing some tests using PostgreSQL 9.5 and jOOQ 3.8.4.
Specifically, I want to create a domain like the following:
CREATE DOMAIN my_something NUMERIC(4,2);
then I want to create a type as follows:
CREATE TYPE my_type (
something my_something;
);
and finally, I have a table that has a the type as a field, e.g.:
CREATE TABLE (
id bigserial;
type my_type;
);
I see that jOOQ 3.8.4 generates the mapping of the field something
as Object
(both int the table record and in the POJO). I was expecting BigDecimal
since the domain uses a NUMERIC
.
Am I wrong? If not, is there any way to overcome the issue?
Maybe I could use customTypes
and forcedTypes
to register a converter, but I'm not sure it works with user defined types! Any experience on this side?
PostgreSQL (or any other database's) data type domains are not yet fully supported in jOOQ 3.8. This is a pending feature request: https://github.com/jOOQ/jOOQ/issues/681
In the meantime, indeed you should use a
forcedType
here to rewritemy_type.something
toNUMERIC
. More info here: http://www.jooq.org/doc/latest/manual/code-generation/data-type-rewritesThat's the easiest way. You could of course also write your own data type binding for a more complete solution, but I think it isn't necessary in this case. More info about data type bindings here: http://www.jooq.org/doc/latest/manual/code-generation/custom-data-type-bindings