ThreeTen-JPA Oracle EclipseLink

Extensions for Oracle and EclipseLink

License

License

MIT
Categories

Categories

CLI User Interface EclipseLink Data ORM
GroupId

GroupId

com.github.marschall
ArtifactId

ArtifactId

threeten-jpa-oracle-eclipselink
Last Version

Last Version

1.12
Release Date

Release Date

Type

Type

jar
Description

Description

ThreeTen-JPA Oracle EclipseLink
Extensions for Oracle and EclipseLink

Download threeten-jpa-oracle-eclipselink

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.marschall/threeten-jpa-oracle-eclipselink/ -->
<dependency>
    <groupId>com.github.marschall</groupId>
    <artifactId>threeten-jpa-oracle-eclipselink</artifactId>
    <version>1.12</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.marschall/threeten-jpa-oracle-eclipselink/
implementation 'com.github.marschall:threeten-jpa-oracle-eclipselink:1.12'
// https://jarcasting.com/artifacts/com.github.marschall/threeten-jpa-oracle-eclipselink/
implementation ("com.github.marschall:threeten-jpa-oracle-eclipselink:1.12")
'com.github.marschall:threeten-jpa-oracle-eclipselink:jar:1.12'
<dependency org="com.github.marschall" name="threeten-jpa-oracle-eclipselink" rev="1.12">
  <artifact name="threeten-jpa-oracle-eclipselink" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.marschall', module='threeten-jpa-oracle-eclipselink', version='1.12')
)
libraryDependencies += "com.github.marschall" % "threeten-jpa-oracle-eclipselink" % "1.12"
[com.github.marschall/threeten-jpa-oracle-eclipselink "1.12"]

Dependencies

compile (1)

Group / Artifact Type Version
com.github.marschall : threeten-jpa-oracle-impl jar 1.12

provided (7)

Group / Artifact Type Version
com.github.marschall : threeten-jpa-oracle-api jar 1.12
org.eclipse.persistence : javax.persistence jar 2.2.1
org.eclipse.persistence : org.eclipse.persistence.jpa jar 2.7.3
org.eclipse.persistence : org.eclipse.persistence.oracle jar 2.7.3
org.jboss.spec.javax.xml.bind : jboss-jaxb-api_2.2_spec jar 1.0.5.Final
org.jboss.spec.javax.annotation : jboss-annotations-api_1.2_spec jar 1.0.2.Final
org.hibernate : hibernate-jpamodelgen jar 5.4.0.Final

test (13)

Group / Artifact Type Version
com.github.marschall : threeten-jpa-test jar 1.12
org.eclipse.persistence : org.eclipse.persistence.extension jar 2.7.3
org.springframework : spring-context jar 5.1.3.RELEASE
org.springframework : spring-test jar 5.1.3.RELEASE
org.springframework : spring-orm jar 5.1.3.RELEASE
org.junit.jupiter : junit-jupiter-api jar 5.3.2
org.junit.jupiter : junit-jupiter-params jar 5.3.2
org.junit.jupiter : junit-jupiter-engine jar 5.3.2
org.junit.platform : junit-platform-launcher jar 1.3.2
org.hamcrest : hamcrest-junit jar 2.0.0.0
org.apache.logging.log4j : log4j-core jar 2.11.1
org.apache.logging.log4j : log4j-jcl jar 2.11.1
org.apache.logging.log4j : log4j-jul jar 2.11.1

Project Modules

There are no modules declared in this project.

ThreeTen JPA Maven Central Build Status

JPA attribute converters for JSR-310 (Java 8) dates and times.

This project was stop gap measure until JPA_SPEC-63 was fixed in JPA 2.2. However JSR-310 support in JPA is not ready for prime time. The project serves the following purposes:

  1. provide JSR-310 support for users on JPA 2.1
  2. provide support for additional JSR-310 data types not specified by JPA 2.2
  3. provide workarounds for driver bugs and missing driver features
  4. provide workarounds for JPA implementation bugs

We take inspiration from the JDBC 4.2 and currently support the following conversions:

ANSI SQL Java SE 8
DATE LocalDate
TIME LocalTime
TIMESTAMP LocalDateTime
TIMESTAMP WITH TIMEZONE OffsetTime (*)
TIMESTAMP WITH TIMEZONE ZonedDateTime (*)
INTERVAL YEAR TO MONTH Period (*)
INTERVAL DAY TO SECOND Duration (*)

(*) requires special extensions, see below

Not supported is converting TIME WITH TIMEZONE to OffsetTime because it seems not very useful.

This project requires Java SE 8 (for the date and time classes) and JPA 2.1 (for the attribute converters). Java SE 9 is supported as well.

This project is very similar to montanajava/jpaattributeconverters or perceptron8/datetime-jpa and can be used in much the same way.

Usage

<dependency>
    <groupId>com.github.marschall</groupId>
    <artifactId>threeten-jpa</artifactId>
    <version>1.12</version>
</dependency>
<persistence-unit>
    …
    <class>com.github.marschall.threeten.jpa.LocalTimeConverter</class>
    <class>com.github.marschall.threeten.jpa.LocalDateConverter</class>
    <class>com.github.marschall.threeten.jpa.LocalDateTimeConverter</class>
    …
</persistence-unit>
@Entity
public class SampleEntity {

  @Column
  private LocalDate localDate;

  @Column
  private LocalTime localTime;

  @Column
  private LocalDateTime localDateTime;
  
}

All the converters have set Converter#autoApply() to true so they're automatically applied to all entities in the same persistence unit.

Converters

You can find a complete list of all converters in the Javadoc

Time Zone Support

Time Zone Support is documented on the wiki.

Interval Support

Oracle Interval Support is documented on the wiki.

Hibernate 5.x

If you are on Hibernate 5.x and JDBC driver properly supports JDBC 4.2 we strongly recommend using the UserTypes from the threeten-jpa-jdbc42-hibernate subproject.

If your driver does not support JDBC 4.2 the hibernate-java8 module introduced in Hibernate 5.0.0 (no longer needed for Hibernate 5.2.0) provides functionality that is equivalent to threeten-jpa and we recommend you use the Hibernate support instead.

Project Structure

The project includes the following submodule:

  • threeten-jpa contains portable converters.
  • threeten-jpa-oracle-eclipselink contains extensions that work only with Oracle in combination with EclipseLink to map TIMESTAMP WITH TIMEZONE to ZonedDateTime or OffsetDateTime.
  • threeten-jpa-h2-eclipselink contains extensions that work only with H2 in combination with EclipseLink to map TIMESTAMP WITH TIMEZONE to OffsetDateTime.
  • threeten-jpa-mssql-eclipselink contains extensions that work only with an old SQL Server driver in combination with EclipseLink to map DATETIMEOFFSET to OffsetDateTime.
  • threeten-jpa-mssql-hibernate contains extensions that work only with an old SQL Server driver SQL Server in combination with Hibernate to map DATETIMEOFFSET to OffsetDateTime.
  • threeten-jpa-oracle-hibernate contains extensions that work only with Oracle in combination with Hibernate to map TIMESTAMP WITH TIMEZONE to ZonedDateTime to OffsetDateTime.
  • threeten-jpa-jdbc42-hibernate contains extensions that work with any JDBC 4.2 compliant driver in combination with Hibernate. They map
  • TIMESTAMP WITH TIMEZONE to ZonedDateTime or OffsetDateTime
  • TIMESTAMP [ WITHOUT TIME ZONE ] to LocalDateTime
  • TIME to LocalTime
  • threeten-jpa-oracle-impl contains the type conversion code from Oracle types to Java 8 types.
  • threeten-jpa-zoned-hibernate contains composite user types to support ZonedDateTime.

Tested with following JPA providers:

  • EclipseLink
  • Hibernate

Tested with the following databases:

  • Derby
  • Firebird
  • H2
  • HSQL
  • MariaDB
  • MySQL
  • Oracle
  • PostgreS
  • SQL Server

DB2 is currently not supported as IBM does not ship a JDBC 4.2 driver.

License

This project is licensed under the MIT license.

Versions

Version
1.12
1.11
1.10.0
1.9.1
1.9.0
1.8.1
1.8.0
1.7.0
1.6.0
1.5.1
1.5.0
1.4.1
1.4.0
1.3.0
1.2.1
1.2.0
1.1.0
1.0.1