Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Trouble retrieving Oracle TIMESTAMPTZ type(Error retrieving timezone's from Oracle DB.)
Trouble retrieving Oracle TIMESTAMPTZ type [message #994151] Wed, 26 December 2012 14:55 Go to next message
Wan Li is currently offline Wan LiFriend
Messages: 4
Registered: December 2012
Junior Member
Hi all,

I am writing an application with uses JPA with GlassFish 3.1.2.2 and EclipseLink 2.3.2. I am using Oracle DB 11g and trying to store and retrieve date and times with timezone using the TIMESTAMPTZ field type.


When retrieving the data from the TIMESTAMPTZ, I am getting the following exception:

Exception [EclipseLink-3002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ConversionException Exception Description: The object [oracle.sql.TIMESTAMPTZ@12cbe3f], of class [class oracle.sql.TIMESTAMPTZ], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[startDateTime-->APPT_EVENT.START_DATE_TIME]] with descriptor [RelationalDescriptor(com.ntst.caremanager.server.entities.ApptEvent --> [DatabaseTable(APPT_EVENT)])], could not be converted to [class java.util.Date].


Has anyone ever encountered this before? This is how my the 'startDateTime' field in my entity class is set up:

@Column(name = "START_DATE_TIME")
@Temporal(TemporalType.TIMESTAMP)
private Date startDateTime;


I've also tried this without luck as well:
@Convert("timestamptz")
@TypeConverter(name="timestamptz", dataType=TIMESTAMPTZ.class)
@Column(name = "START_DATE_TIME")
@Temporal(TemporalType.TIMESTAMP)
private Date startDateTime;


I have read on the eclipselink wiki here, under the heading 'Support for oracle.sql.TimeStamp' that EclipseLink natively supports oracle's TIMESTAMPTZ without any conversion necessary. I have also tried using the 'Calendar' type instead of 'Date' time in my entity class without luck.

Has anyone seen this issue before, or see any error I may have made?

Thank you!
Re: Trouble retrieving Oracle TIMESTAMPTZ type [message #995928 is a reply to message #994151] Mon, 31 December 2012 14:44 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
You didn't mention if you are using the Oracle9Platform or later DatabasePlatform subclasses using the eclipselink.target-database persistence property. For example:

<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.oracle.Oracle10Platform"/>
<property name="eclipselink.target-server" value="SunAS9"/>

You will probably also need to remove the @Temporal(TemporalType.TIMESTAMP) annotation, as this specifies a conversion from Date to/from sql.Timstamp instead of the Oracle TIMESTAMPTZ, and is likely conflicting with and overriding the @Convert annotation.

Best Regards,
Chris
Re: Trouble retrieving Oracle TIMESTAMPTZ type [message #996814 is a reply to message #995928] Thu, 03 January 2013 00:29 Go to previous message
Wan Li is currently offline Wan LiFriend
Messages: 4
Registered: December 2012
Junior Member
Hi Chris,

Thanks. Actually yes, I am using Oracle11Platform.
I investigated this further today and found the issue is actually my error.

I made an omission where I forgot to put ojdbc6.jar file in the glassfish\domains\domain1\lib\ext\ directory. Without it there, EclipseLink couldn't find the oracle.sql.timestamptz type to convert.

After doing that, all I needed was
@Column(name = "START_DATE_TIME")
@Temporal(TemporalType.TIMESTAMP)
private Calendar startDateTime;


Everything worked after that. It appears in the latest EclipseLink version, you don't need to explicitly use the @Convert and @TypeConverter annotations, EclipseLink will take care of it for you.
Also, I noticed I could leave out:
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.oracle.Oracle11Platform"/>
<property name="eclipselink.target-server" value="SunAS9"/>


EclipseLink autodetected the correct platform to use.

Thanks for your help, your reply led me down the right path.
Previous Topic:JPA meta-model getJavaMember does not work with dynamic JPA
Next Topic:Bad EclipseLink JPA dependency
Goto Forum:
  


Current Time: Fri Apr 26 21:52:33 GMT 2024

Powered by FUDForum. Page generated in 0.03119 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top