-
Notifications
You must be signed in to change notification settings - Fork 6
Oracle Time Zone Support
Using time zones with Oracle provides the greatest flexibility as both OffsetDateTime
and ZondedDateTime
are natively supported.
threeten-jpa-oracle-eclipselink
contains JPA attribute converters which need to be listed in persistence.xml
<persistence-unit>
…
<class>com.github.marschall.threeten.jpa.oracle.OracleOffsetDateTimeConverter</class>
<class>com.github.marschall.threeten.jpa.oracle.OracleZonedDateTimeConverter</class>
…
</persistence-unit>
When using the Oracle11
and Oracle12
platforms instead of the generic Oracle
platform and mapping TIMESTAMP WITH TIME ZONE
to java.sql.Timestamp
or java.util.Calendar
in addition to OffsetDateTime
or ZonedDateTime
you'll be affected by bug 511999. As a work around we provide the following platforms:
- com.github.marschall.threeten.jpa.oracle.PatchedOracle11Platform
- com.github.marschall.threeten.jpa.oracle.PatchedOracle12Platform
As of ojdbc8 18.3 we recommend using Hibernate user types from threeten-jpa-jdbc42-hibernate
for OffsetDateTime
, ZonedDateTime
and LocalDateTime
. User types from threeten-jpa-oracle-hibernate
should only be used for Oracle Interval Support.
@Entity
public class SampleEntity {
@Column
@Type(type = Jdbc42ZonedDateTimeType.NAME)
private ZonedDateTime zonedDateTime;
@Column
@Type(type = Jdbc42OffsetDateTimeType.NAME)
private OffsetDateTime offsetDateTime;
}
Note the Oracle driver module has to be visible to the deployment (e.g Class Loading in WildFly).