Unable to retrieve TIMESTAMPTZ from Oracle [message #1831381] |
Tue, 18 August 2020 14:01  |
Eclipse User |
|
|
|
I am using Eclipselink 2.7.6p1 that comes with Payara, Oracle 12c, Payara 5.2020.4 and I get a conversion exception when running a query.
The exception thrown is:
Exception Description: The object [oracle.sql.TIMESTAMPTZ@cef6f7b], of class [class oracle.sql.TIMESTAMPTZ], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[runStartTime-->ASR_RUN.RUN_START_TIME]] with descriptor [RelationalDescriptor(<packagename_removed>.ASRRun --> [DatabaseTable(ASR_RUN)])], could not be converted to [class java.util.Date].
at org.eclipse.persistence.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:81)
at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToUtilDate(ConversionManager.java:1025)
at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:109)
at org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:226)
at org.eclipse.persistence.mappings.converters.TypeConversionConverter.convertDataValueToObjectValue(TypeConversionConverter.java:125)
at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.getObjectValue(AbstractDirectMapping.java:605)
at org.eclipse.persistence.queries.ReportQueryResult.processItemFromMapping(ReportQueryResult.java:186)
at org.eclipse.persistence.queries.ReportQueryResult.processItem(ReportQueryResult.java:226)
The Entity definition is:
```
@Column(name = "RUN_START_TIME")
@Temporal(TemporalType.TIMESTAMP)
private Date runStartTime;
@Column(name = "RUN_STOP_TIME")
@Temporal(TemporalType.TIMESTAMP)
private Date runStopTime;
```
The persistence.xml file has the following properties:
<properties>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.Oracle12Platform"/>
<property name="eclipselink.target-server" value="Glassfish"/>
</properties>
And I have added the following dependencies to my POM.xml:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.oracle</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.3.0.0</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.7.6</version>
</dependency>
I also added ojdbc10.jar to the payara domain's lib directory as suggested by a colleague.
I have tried changing the java type to various other types such as java.time.OffsetDateTime. It is almost as if it can't find the convert functions for the db data type.
Does anybody have any suggestions on what I could be doing wrong? I have seen a couple of other threads with regards to this but most don't have solutions/answers and the others seem to suggest what I have defined should be sufficient. I have this same code base working against MS SQL as well.
I'm still not sure what could be misconfigured.
[Updated on: Wed, 19 August 2020 11:06] by Moderator
|
|
|
|
|
|
|
|
|
|
|
Re: Unable to retrieve TIMESTAMPTZ from Oracle [message #1831724 is a reply to message #1831699] |
Thu, 27 August 2020 09:57  |
Eclipse User |
|
|
|
To begin I just wanted to thank you Chris for your replies. I have posted in a number of locations and you have been the most helpful by far.
In my original post, I had specified Glassfish but I have since moved to Payara being specified in the persistence.xml. As payara was derived from glassfish, many things require glassfish to be specified. After adding Payara, I didn't get any errors so I stuck with that. As for the change from Oracle12Platform to Oracle 10Platform. I am using jdbc10 jdbc libraries so I thought that would bring them into alignment.
In all honesty, part of my problem is not understanding which JDBC drivers to use with which version of java with which version of oracle with which version of eclipselink.
This is a run down of my setup:
Payara 5.2020.4
Oracle 12c - 12.1.0.1
ojdbc10-19.3.0.0.jar
eclipselink 2.7.6.payara-p1 (version that ships with payara)
If you know of a configuration which works with specific versions of all of these I would be happy to try it. Thank you for your hlep.
|
|
|
Powered by
FUDForum. Page generated in 0.06603 seconds