-->
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.  [ 4 posts ] 
Author Message
 Post subject: question about hql
PostPosted: Thu Jul 06, 2006 6:50 pm 
Newbie

Joined: Thu Jul 06, 2006 6:47 pm
Posts: 2
Hibernate version:
3.0
Name and version of the database you are using:
DB2


Does hibernate hql has any query to retrieve the "current timestamp" from the database? . I'm trying to retrieve the "current timestamp" from DB2 Database to perform some business.

will appreciate your reply
thanks
Shankar


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 7:14 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Use an SQL query for that.
Code:
<sql-query name="CurrentTimestamp">
  <return-scalar name="curTime" type="datetime"/>
  select CURRENT TIMESTAMP as curTime
</sql-query>
I think that's how you do it on DB2.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 8:36 pm 
Newbie

Joined: Thu Jul 06, 2006 6:47 pm
Posts: 2
Thanks for your reply.

How could I use "VALUES (CURRENT TIMESTAMP)" which is one of the query that gets DB2 date time,

I tried the following but didn't work,

<sql-query name="CurrentTimestamp">
<return-scalar column="curTime" type="datetime"/>
VALUES(CURRENT TIMESTAMP)
</sql-query>

Also will I need a domain java class for the above ?

Thanks
Shan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 9:50 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Use "select values (CURRENT TIMESTAMP)". You omitted the select.

No, you don't need a class. The return-scalar element tells hibernate that the result set returns a scalar, not an entity.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.