Is there a similar way to get hold of a write connection - or does it matter?On Mar 24, 2009, at 3:50 PM, Gordon Yorke wrote: ServerSession session = ((EntityManagerImpl)getEntitytManager()).getServerSession(); Accessor accessor = session.getReadConnectionPool().acquireConnection(); accessor.incrementCallCount(); accessor.getConnection() .... //when done accessor.decrementCallCount(); session.getReadConnectionPool().releaseConnection(accessor); --Gordon David Parker wrote: I tried 1.1, and now the code Query query = getEntityManager().createNativeQuery(GET_DATE); Object result = query.getSingleResult(); yields a result Object that is a oracle.sql.TIMESTAMPTZ, which isn't much help. Is there a way I can just get a Connection from the the eclipselink connection pool, and use jdbc to get this simple piece of data. I would rather not have to construct a separate connection pool just for this query, and it is going to be called for every server request, so constructing a new Connection every time is not an option. On Mar 24, 2009, at 3:13 PM, Gordon Yorke wrote: You can try new java.util.Date(timestamptz.timestampValue(null).getTime()), but I am not sure you can make the conversion without a connection. You could also return something similar to "select to_char(sysdate, 'Dy DD-Mon-YYYY HH24:MI:SS') as current_time from dual;" and pass the string directly to new Date(). (details on Oracle date format can be found here : http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html#date%20format ) --Gordon David Parker wrote: Yeah, it's a NonSynchronizedVector with one element, which is a TIMESTAMPTZ. If I just cast to that Vector type, and get the TIMESTAMPTZ object out, is there a straightforward way to turn that into a java.util.Date? Thanks again. - DAP On Mar 24, 2009, at 1:42 PM, Gordon Yorke wrote: It looks like we may have a bug. Can you inspect the result from "query.getSingleResult()" without the cast. You are probably getting a Vector with one element. --Gordon David Parker wrote: 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 _______________________________________________
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 _______________________________________________
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
_______________________________________________
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
|