Unable to retrieve TIMESTAMPTZ from Oracle [message #1831381] |
Tue, 18 August 2020 18:01 |
Aaron Carnes Messages: 7 Registered: August 2020 Location: Seattle, WA |
Junior Member |
|
|
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 15:06] Report message to a moderator
|
|
|
|
|
|
|
Re: Unable to retrieve TIMESTAMPTZ from Oracle [message #1831599 is a reply to message #1831494] |
Mon, 24 August 2020 15:30 |
Chris Delahunt Messages: 1389 Registered: July 2009 |
Senior Member |
|
|
The Oracle12Platform isn't being used or it would appear on the exception stack trace within the conversion - its Oracle9Platform parent overrides the DatasourcePlatform.convertObject method to add TIMESTAMPTZ support for this operation (it converts it to an EclipseLink TIMESTAMPLTZWrapper class before this part).
Logging while the persistence unit is being deployed and first accessed may indicate how it is getting the connection and the DatabasePlatform class to use. Connection unwrapping is required, but should result in an exception if the Oracle connection cannot be obtained from under the datasource provided connection, as it should be passed to TIMESTAMPLTZ.toTimestamp(connection, tsLTZ.toBytes()); for conversion operations earlier in the stack.
[Updated on: Mon, 24 August 2020 15:31] Report message to a moderator
|
|
|
Re: Unable to retrieve TIMESTAMPTZ from Oracle [message #1831637 is a reply to message #1831599] |
Tue, 25 August 2020 18:46 |
Aaron Carnes Messages: 7 Registered: August 2020 Location: Seattle, WA |
Junior Member |
|
|
I added the logging and I noticed I am getting this in the output:
EclipseLink, version: Eclipse Persistence Services - 2.7.6.payara-p1|#]
connecting(DatabaseLogin(
platform=>Oracle10Platform
user name=> ""
connector=>JNDIConnector datasource name=>null
))|#]
...
Missing class details for [oracle/sql/TIMESTAMPTZ].|#]
Using existing class bytes for [oracle/sql/TIMESTAMPTZ].|#]
Missing class details for [oracle/jdbc/internal/OracleTimestampWithTimeZone].|#]
...
I also tried with Oracle12Platform and got the same result.
Is it possible I am using the incorrect library. Is the support for this in the JDBC drivers or in some other jar?
The entries in my POM xml are:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.oracle</artifactId>
<version>2.7.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 -->
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.3.0.0</version>
</dependency>
[Updated on: Tue, 25 August 2020 18:47] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03844 seconds