Hi Lukas,

Many thanks for the heads up.

This seems to do the trick, if I increase the scope of the match
expression to include "NUMBER".

This is the DDL that JOOQ has introspected (as logged by the generator):

[DEBUG] Fetched result           :
+---------------+---------+-----------+--------------+----------+--------+--------------------------------------+-----------+---------+--------+
[DEBUG]                          :
|DATA_TYPE_OWNER|DATA_TYPE|char_length|DATA_PRECISION|DATA_SCALE|NULLABLE|DATA_DEFAULT
                         |COLUMN_NAME|COLUMN_ID|COMMENTS|
[DEBUG]                          :
+---------------+---------+-----------+--------------+----------+--------+--------------------------------------+-----------+---------+--------+
[DEBUG]                          : |{null}         |NUMBER   |
 0|            19|         0|N
|"SUBSCRIPTIONS"."ISEQ$$_92197".nextval|ID         |        1|{null}
|
[DEBUG]                          : |{null}         |VARCHAR2 |
100|        {null}|    {null}|Y       |{null}
      |NAME       |        2|{null}  |
[DEBUG]                          :
+---------------+---------+-----------+--------------+----------+--------+--------------------------------------+-----------+---------+--------+

So if I use the expression

<types>NUMBER(19)|NUMBER(19,0)</types>

I get the following output from the generator:

$ mvn clean compile -X | grep 'TENANTS\.ID'
[DEBUG] Adding primary key       : SYS_C0010277 (SUBSCRIPTIONS.TENANTS.ID)
[DEBUG] Type mapping             : SUBSCRIPTIONS.TENANTS.ID with type NUMBER

and the type is mapping to the default, BigInteger.

If I expand the matcher thusly

<types>NUMBER</types>

The forced type takes effect:

$ mvn clean compile -X | grep 'TENANTS\.ID'
[DEBUG] Adding primary key       : SYS_C0010277 (SUBSCRIPTIONS.TENANTS.ID)
[DEBUG] Type mapping             : SUBSCRIPTIONS.TENANTS.ID with type NUMBER
[INFO] Forcing type             : SUBSCRIPTIONS.TENANTS.ID with type
NUMBER into BIGINT

Does the matcher maybe need to be sensitive of the precision and scale?

Cheers,

Ben


On Fri, Dec 4, 2015 at 7:58 AM, Lukas Eder <[email protected]> wrote:
> The most straightforward way would be to use data type rewriting:
> http://www.jooq.org/doc/latest/manual/code-generation/data-type-rewrites
>
>     <forcedType>
>       <!-- Specify any data type from org.jooq.impl.SQLDataType -->
>       <name>BOOLEAN</name>
>
>       <!-- Add a Java regular expression matching fully-qualified columns.
> Use the pipe to separate several expressions.
>
>            If provided, both "expressions" and "types" must match. -->
>       <expression>.*\.IS_VALID</expression>
>
>       <!-- Add a Java regular expression matching data types to be forced to
> have this type.
>
>            Data types may be reported by your database as:
>            - NUMBER
>            - NUMBER(5)
>            - NUMBER(5, 2)
>            - any other form.
>
>            It is thus recommended to use defensive regexes for types.
>
>            If provided, both "expressions" and "types" must match. -->
>       <types>.*</types>
>     </forcedType>
>
>
> Or, in your case:
>
>     <forcedType>
>       <name>BIGINT</name>
>       <expression>.*</expression>
>       <types>NUMBER(19)|NUMBER(19,0)</types>
>     </forcedType>
>
>
> I've put both versions, with or without scale - I'm not sure right now which
> one will work.
>
> Let me know if this works for you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to