Jooq: Add <javaTimeTypes/> to code generator configuration to generate Java 8 java.time types instead of java.sql types

Created on 27 Jul 2015  路  11Comments  路  Source: jOOQ/jOOQ

The new Java 8 API (see #3645) should support generating java.time types by default, rather than the insufficient java.sql types. This is useful when supporting { TIME | TIMESTAMP } WITH TIME ZONE types.

The JDBC spec (http://download.oracle.com/otndocs/jcp/jdbc-4_2-mrel2-eval-spec/index.html) specifies:

  • Added support to map java.time.LocalDate to JDBC DATE.
  • Added support to map java.time.LocalTime to JDBC TIME
  • Added support to map java.time.LocalDateTime to JDBC TIMESTAMP.
  • Added support to map java.time.OffsetTime to JDBC TIME_WITH_TIMEZONE.
  • Added support to map java.time.OffsetDateTime to JDBC TIMESTAMP_WITH_TIMEZONE.
Code Generation High Fixed Enhancement

Most helpful comment

@eiswind: Unfortunately, no progress yet. Chances are, that jOOQ 3.9 will be delayed a bit to get this in, though. It's really a priority to finally support JSR 310 in jOOQ

All 11 comments

When will you release v3.7?
I really want to change the time type.

And, could it be easily implement on v 3.6.x?

Thanks a lot for your works.

You can always use Converter for custom java.time types

3.7 is due for the end of September

We won't be able to add support for JSR-310 in jOOQ 3.7's code generator. There are still too many open questions. Only the runtime will be capable of handling these data types.

When implementing date-time handling functions for Java 8, please also keep in mind possibility to use other types such as Instant and Duration (for intervals).

Yes, indeed. Duration corresponds to SQL's INTERVAL DAY TO SECOND, whereas YearMonth corresponds to SQL's INTERVAL YEAR TO MONTH

Is there any progress on this one or do I still need to use custom types?

@eiswind: Unfortunately, no progress yet. Chances are, that jOOQ 3.9 will be delayed a bit to get this in, though. It's really a priority to finally support JSR 310 in jOOQ

This is now implemented as an opt-in flag. With more end user experience, we'll eventually switch the flag's default value to true (https://github.com/jOOQ/jOOQ/issues/5714)

Hi @lukaseder I just wanted to thank you for implementing this feature! I started migrating to jooq a few weeks back and was eagerly looking forward to java.time API support :-)
Many thanks (and apologies for the off-topic comment)!

Hey, you're welcome, "@stupidSheep" :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukaseder picture lukaseder  路  7Comments

bhemar picture bhemar  路  5Comments

lukaseder picture lukaseder  路  4Comments

bennofs picture bennofs  路  4Comments

krzysztof-osiecki picture krzysztof-osiecki  路  6Comments