users@glassfish.java.net

Re: Toplink conversion error using util.Date/sql.Date and Timestamps

From: Kenneth Clark <kenneth_at_rabiddog.co.za>
Date: Wed, 07 Feb 2007 16:15:59 +0200

On first glance I am inclined to believe that the issue is the casting
of the object but I might be wrong.

Have you tried using a Timestamp Object?

Kenneth Clark
Developer / Analyst

Rabid Dog Laboratories ™
Putting the art back into development

*tel:* +27 11 475 7409
*mobile:* +27 82 500 5090
*e-mail:* kenneth_at_rabiddog.co.za
*website:* http://www.rabiddog.co.za/


glassfish_at_javadesktop.org wrote:
> Hello,
>
> I'm currently wrecking my nerves on an issue I thought to be very simple using JPA via Toplink. I have defined an Entity-Class called Aufgabe with a persistent field startDate. This field is mapped to a database table in my local Oracle XE of type TIMESTAMP.
>
> The specific part of the entity class looks as follows:
>
> @Temporal(value=TemporalType.TIMESTAMP)
> private java.util.Date _startdatum;
>
> When I deploy my application to Glassfish, the verifier signals 0 errors/warnings, but when I query the database via JPA for Aufgabe-Objects, I get the following exception:
>
> Exception [TOPLINK-3002] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.ConversionException
> Exception Description: The object [oracle.sql.TIMESTAMPLTZ_at_96af55], of class [class oracle.sql.TIMESTAMPLTZ], from mapping [oracle.toplink.essentials.mappings.DirectToFieldMapping[startdatum-->AUFGABEN.STARTDATUM]] with descriptor [RelationalDescriptor(myapp.Aufgabe --> [DatabaseTable(AUFGABEN)])], could not be converted to [class java.util.Date].
>
> I tried omitting the @Temporal annotation (what is invalid), I tried changing to java.sql.Date without the annotation, resulting in nearly the same error.
>
> What exactly am I doing wrong? Should I use Timestamp instead of Date? Should I change the column type in the database from TIMESTAMP to DATE? Seems JPA is not as easy as I thought.
>
> Thank you for your help!
>
> Hendrik Busch
> [Message sent by forum member 'hbusch' (hbusch)]
>
> http://forums.java.net/jive/thread.jspa?messageID=202435
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>
>
>