Code generation for 3.10 creates OffsetDateTime need Timestamps

69 views
Skip to first unread message

Robert Mattler

unread,
Oct 4, 2017, 9:20:25 AM10/4/17
to jOOQ User Group
Upgraded to 3.10 and the code generation is creating 

    private OffsetDateTime createdOn;


This breaks everything in the front end application since it doesn't know how to handle OffsetDateTime.  


Added dateAsTimestamp but this effected the dates.  Just want the timestamps back.  Thanks in advance.


<configuration>
  <generator>
    <database>
      <dateAsTimestamp>true</dateAsTimestamp>
    </database>
  </generator>
</configuration>


Using PostgreSQL 9.6.2.

Lukas Eder

unread,
Oct 4, 2017, 9:30:42 AM10/4/17
to jooq...@googlegroups.com
Hi Robert,

Thanks for your message. Where did you upgrade from? And what's your configuration for <javaTimeTypes/>? Note that <dateAsTimestamp/> is there to indicate that (mostly Oracle's) DATE types should be generated as TIMESTAMP types.

We've added JSR-310 support in jOOQ 3.9. The data type TIMESTAMP WITH TIME ZONE is now mapped to OffsetDateTime. It was erroneously mapped to Timestamp before that, although before supporting Java 8 and JSR-310, there wasn't really any good alternative.

You can always make use of <forcedType/> to rewrite data types for any columns:

I hope this helps
Lukas

--
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 jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Mattler

unread,
Oct 4, 2017, 11:30:00 AM10/4/17
to jOOQ User Group
I used the forced types to fix my problem.  I was trying to avoid that since every time I add a "timestamp with time zone" I have to remember to add it to my code generation pom.xml.  

Thanks for your help and quick response.


<forcedTypes>

   <forcedType>

        <name>TIMESTAMP</name>

<expression>created_on|last_modified_on|fax_response_time|effective_date|assigned_on|transaction_posted_date|transaction_created_date|transaction_deposit_date|time_stamp|created_date</expression>

        <types>.*</types>

  </forcedType>

</forcedTypes>

To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.

Lukas Eder

unread,
Oct 4, 2017, 11:53:30 AM10/4/17
to jooq...@googlegroups.com
Hi Robert,

Two things:

1. Why not just match columns based on their types? You can specify <types>(?i:timestamp with time zone)</types>
2. I'm curious why you're doing this in the first place. The java.sql.Timestamp data type does not have any time zone information associated with it. The PostgreSQL TIMESTAMP WITH TIME ZONE type is in UTC. This means that timestamps are converted to local time (the one of your JDBC client, not the server time, since the server uses TIMESTAMP WITH TIME ZONE). To me, this looks like a nasty bug waiting to happen... I mean, why not just use TIMESTAMP in the server also?

Best Regards,
Lukas

To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages