Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] getting a timestamp value back from a nativeQuery

This is the code:

   public Date getSystemDate() {
        Query query = getEntityManager().createNativeQuery("select systimestamp from dual");
        Object result[] = (Object[]) query.getSingleResult();
        return (Date) result[0];
    }

This throws  
java.lang.ClassCastException: org.eclipse.persistence.internal.helper.NonSynchronizedVector
on the getSingleResult Line.

(The return statement is probably wrong, too, but it doesn't seem to be getting there...)

Thanks.

On Mar 24, 2009, at 12:44 PM, Gordon Yorke wrote:

Why is this not working?  Are you getting an exception?  You should expects an Object[] with a single element of timestamp.
--Gordon

David Parker wrote:
I need to execute a "select systimestamp from dual" against a 10g database. I'd like to use a JPA nativeQuery rather than going to JDBC, but I cannot for the life of me figure out how to get a timestamp object back from a Query.getSingleResult().

I just want to get a system time from a central place (the database) in a distributed system. Is there a better way to do this, if it isn't possible via a jpa native query?

=============================================
David Parker
dap@xxxxxxxxxxxxxxxxxxxx




_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


=============================================
David Parker





Back to the top