Hi Lukas

I've possibly found a workaround.

Instead of the option dateAsTimestamp I declare a converter in the code 
generation's config:

<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.10.0.xsd";>
    <!-- Configure the database connection here -->
    <jdbc>

         ...
    </jdbc>

    <generator>

        <database>

            ...

            <!-- 
https://www.jooq.org/doc/3.11/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-date-as-timestamp/
            <dateAsTimestamp>true</dateAsTimestamp>
            -->

            <!-- Associate data type rewrites with database columns -->
            <forcedTypes>
                <forcedType>

                    <userType>java.sql.Timestamp</userType>

                    
<converter>....persistence.database.jooq.converter.OracleDateConverter</converter>


                    <!-- 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>....</expression>

                    <types>DATE</types>

                </forcedType>

            </forcedTypes>
        </database>

...


and provide a converter like

public class OracleDateConverter extends AbstractConverter<java.sql.Date, 
java.sql.Timestamp> {


    public OracleDateConverter() {
        this(java.sql.Date.class, java.sql.Timestamp.class);

    }

    public OracleDateConverter(Class<Date> fromType, Class<Timestamp> toType) {
        super(fromType, toType);
    }

    @Override
    public Timestamp from(Date databaseObject) {
        if(databaseObject == null) {
            return null;
        }
        return new Timestamp(databaseObject.getTime());
    }

    @Override
    public Date to(Timestamp userObject) {
        if(userObject == null) {
            return null;
        }
        return new Date(userObject.getTime());
    }
}


Regards,
Urs

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