2

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?

JeanValjean
  • 17,172
  • 23
  • 113
  • 157

2 Answers2

1

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 rewrite my_type.something to NUMERIC. More info here: http://www.jooq.org/doc/latest/manual/code-generation/data-type-rewrites

That'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

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • @RobertoTrunfio: Glad to hear that. Did you know, on Stack Overflow, you can also answer your own question (e.g. instead of putting a partial answer in your question) – Lukas Eder Sep 12 '16 at 17:23
  • I know, I did it in the past. I actually do not like to do that when I just formalize another's answer. I feel like a thief. Another option was to enrich your answer, which I also do not like so much when it comes to major changes – JeanValjean Sep 12 '16 at 18:25
  • @RobertoTrunfio: Why do you feel like a thief? :) You're adding value to the next visitor... – Lukas Eder Sep 13 '16 at 06:45
1

As suggested by Lukas Eder, I just added

<forcedType>
  <name>NUMERIC(4,2)</name>
  <expression>my_type.something</expression>
  <types>.*</types>
</forcedType>

and worked very well.

Community
  • 1
  • 1
JeanValjean
  • 17,172
  • 23
  • 113
  • 157