-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Get current timestamp from sysibm.sysdummy1
PostPosted: Thu Jan 05, 2006 7:17 pm 
Newbie

Joined: Thu Oct 30, 2003 5:31 pm
Posts: 4
Hibernate version: 3

Mapping documents: hbm files

Name and version of the database you are using: DB2 version 7 on os/390

I am trying to execute the following query
Code:
SELECT current timestamp FROM SYSIBM.SYSDUMMY1


When I try to run this in a session.createQuery I get
Code:
*** ERROR:  SYSIBM.SYSDUMMY1 is not mapped.


I read that I probably need to do a stored procedure execution here http://www.hibernate.org/hib_docs/v3/re ... /#sp_query

But this sqlQuery returns a class and I need a timestamp returned which is basically the timestamp from the database I am operating with.

How can I get this done? Any clues?

Thanks.

T.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 7:45 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
When selecting from an unmapped table, you must use sql-query, not query. Equivalently, use Session.createSQLQuery, not Session.createQuery. You'll also need to specify the type of the returned scalar. Both the reference doc and the javadocs are helpful for this.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 11:17 am 
Newbie

Joined: Thu Oct 30, 2003 5:31 pm
Posts: 4
This is what worked. Thanks for pointing in the right direction

Code:
List utcTime = (List) HibernateUtil.getSession().createSQLQuery(
               "SELECT current timestamp as ts FROM SYSIBM.SYSDUMMY1").addScalar("ts",Hibernate.TIMESTAMP).list();
         log.debug("utcTime = " + utcTime);



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.