javasqljooq

How to Force all DATE columns to LocalDateTime in jOOQ generator?


I want to force all Oracle DATE columns to LocalDateTime.

What I tried:

<forcedType>
    <name>LOCALDATETIME</name>
    <userType>java.time.LocalDateTime</userType>
    <types>DATE\(*\)</types>
</forcedType>

But jOOQ still generates LocalDate.

How must the forcedType look like?


Solution

  • Your <types> expression reads "DATE followed by any number of ( followed by exactly one ). You probably wanted this:

    <types>DATE(\(.*\))?</types>
    

    As a side note: You don't really need to specify the <userType> to profit from the "data type rewriting" feature. Specifying a name that matches a type from SQLDataType is enough.

    Bug

    Notice there was a bug in jOOQ 3.11 by which <name>LOCALDATETIME</name> did not work: https://github.com/jOOQ/jOOQ/issues/8493

    This is fixed in jOOQ 3.12. For the time being, use <name>TIMESTAMP</name> instead, along with <javaTimeTypes>