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]>: > 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]. > 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.
