Hi, Thank you for this extra explanation! Indeed, that's what I thought when I tried to configure data type rewritting but I wasn't totally sure about how it worked. As you well said, it's worth clarifying it in the documentation so that avoiding misunderstanding.
Now, returing to my problem: using PLS_INTEGER <https://www.jooq.org/javadoc/3.10.x/index.html?org/jooq/util/oracle/OracleDataType.html> worked as expected! So follows my final configuration: <forcedTypes> <forcedType> <name>PLS_INTEGER</name> <expression>.*\.ID_.*</expression> <types>NUMBER</types> </forcedType> </forcedTypes> Thanks again, Lukas! On Tuesday, May 15, 2018 at 9:09:11 AM UTC-3, Lukas Eder wrote: > > Well, that just helps explaining it. You have to think of it this way: > You're re-writing the data type to some other type, prior to feeding the > data type to the code generator. The code generator will think that the > dictionary views produced the type you're providing, so it'll treat them as > vendor-specific. > > I guess this could be clarified in the manual... > > 2018-05-15 13:40 GMT+02:00 Rafael Ponte <[email protected] <javascript:>>: > >> Hi, >> >> Thanks for this explanation, very helpful. >> >> It makes sense! I didn't know jOOQ used the OracleDataType instead of >> SQLDataType, that's a very important info! >> >> I'll try these suggested data types today and later I give a feedback. >> >> Thanks, Lukas! >> >> On Tue, 15 May 2018 at 04:31 Lukas Eder <[email protected] <javascript:>> >> wrote: >> >>> Hi Rafael, >>> >>> Thanks for your detailed description. The approach you've chosen is >>> correct, but the problem is that Oracle's idea of an INTEGER data type is >>> really best represented by BigInteger, so the data type rewriting doesn't >>> really rewrite the type to SQLDataType, but to [Dialect]DataType. In this >>> case, OracleDataType.INTEGER is a BigInteger. Try it in Oracle: >>> >>> CREATE TABLE t (i INTEGER); >>> >>> SELECT data_type, data_length, data_precision, data_scale >>> FROM user_tab_cols >>> WHERE table_name = 'T'; >>> >>> >>> You'll get >>> >>> DATA_TYPE DATA_LENGTH DATA_PRECISION DATA_SCALE >>> -------------------------------------------------- >>> NUMBER 22 0 >>> >>> >>> So, it's really a BigInteger. In order to get jOOQ to generate a >>> java.lang.Integer, you can rewrite the type to something like NUMBER(8) or >>> BINARY_INTEGER or PLS_INTEGER. >>> >>> I hope this helps, >>> Lukas >>> >>> 2018-05-14 18:07 GMT+02:00 Rafael Ponte <[email protected] <javascript:>> >>> : >>> >>>> Hi guys, >>>> >>>> I'm working on Oracle 11g XE with jOOQ 3.10.6 (trial version) and I'm >>>> trying to use the jOOQ's Data Type Rewrite feature >>>> <https://www.jooq.org/doc/3.10/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-forced-types/> >>>> >>>> but It's not working as I'd like to. >>>> >>>> When I generate my classes via jOOQ generator it is considering all >>>> columns with type NUMBER (without explict precision and scale) as >>>> BigDecimal in Java code. Unfortunately all my tables have PK columns as >>>> NUMBER (again, no precision and no scale) and I can't change it! But what >>>> I >>>> really want is those attributes be of type java.lang.Integer (don't worry, >>>> I understand the risks related to precision here). >>>> >>>> To solve that, I configured jOOQ generator config file to *rewrite all >>>> columns which their names start with "ID_" and are of type NUMBER* >>>> (without explict precision and scale), as you can see below: >>>> >>>> <forcedTypes> >>>> <forcedType> >>>> <name>INTEGER</name> >>>> <expression>.*\.ID_.*</expression> >>>> <types>NUMBER</types> >>>> </forcedType> >>>> </forcedTypes> >>>> >>>> >>>> But it's generating all class attributes as BigInteger instead of >>>> Integer >>>> <https://www.jooq.org/javadoc/3.9.0/org/jooq/impl/SQLDataType.html#INTEGER>. >>>> >>>> For some reason I think it's related to this default jOOQ behavior >>>> <https://stackoverflow.com/questions/39921053/jooq-oracle-number-precision-and-java-number-mapping>. >>>> >>>> The best I've got was generating those attributes as java.lang.Long >>>> through >>>> this configuration: >>>> >>>> <forcedTypes> >>>> <forcedType> >>>> <name>BIGINT</name> >>>> <expression>.*\.ID_.*</expression> >>>> <types>NUMBER</types> >>>> </forcedType> >>>> </forcedTypes> >>>> >>>> >>>> I can't understand why it works for BIGINT but not for INTEGER. >>>> >>>> Someone could give me any tip? >>>> >>>> Thanks, >>>> >>>> -- >>>> 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] <javascript:>. >>>> 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] <javascript:>. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> Rafael Ponte >> TriadWorks | Formação Java >> http://cursos.triadworks.com.br >> >> -- >> 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] <javascript:>. >> 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.
