simran
simran

Reputation: 11

Apache Olingo OData 2.0 doesn't support Java 8 LocalDatetime (java.time)

I am using Apache Olingo version number

olingo-odata2-core:2.0.11
olingo-odata2-jpa-processor-core:2.0.11
olingo-odata2-jpa-processor-ref:2.0.11

When I use java.time.LocalDatetime type in my JPA entity, I got following exception:-

Odata- JPA Type Converter: Type[class. java.time.LocalDateTime] not supported.

Upvotes: 1

Views: 730

Answers (1)

Shiva
Shiva

Reputation: 6885

Its because in file JPATypeConverter.java line 91 its hard coded to only accept the following

else if (jpaType.equals(Date.class) || jpaType.equals(Calendar.class) ||
        jpaType.equals(Timestamp.class) || jpaType.equals(java.util.Date.class))

I tried using the XmlJavaTypeAdapter to make it to accept LocalDateTime, it works fine for getting the value but while setting it errors out because in JPAEntity.java Line 515 it only picks the XmlJavaTypeAdapter if the parameter type is String, maybe this can be fixed in Olingo code or we can add LocalDateTime support in JPATypeConverter

Though not sure this would be worth the effort because I suspect Olingo 2 might be tied to JPA 2 which itself lacked support for LocalDateTime.

Simplest solution would be to use java.sql.Timestamp or one of the supported classes in place of LocalDateTime

Harder solution would be to raise a bug with Olingo and fix it in the codebase

Upvotes: 2

Related Questions