Trouble retrieving Oracle TIMESTAMPTZ type [message #994151] |
Wed, 26 December 2012 09:55  |
Eclipse User |
|
|
|
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 #996814 is a reply to message #995928] |
Wed, 02 January 2013 19:29  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.08847 seconds