-->
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.  [ 2 posts ] 
Author Message
 Post subject: Getting date in simple sql queries
PostPosted: Thu Nov 25, 2004 7:18 am 
Newbie

Joined: Thu Nov 25, 2004 6:43 am
Posts: 2
Hello,

My problem is quite easy. I need to get a database date/time to using query like this: SELECT now() or SELECT CURRENT_TIMESTAMP.

HQL treats now() or CURRENT_TIMESTAMPS as aliases (I don't know how to tell him to pass these to sql). That's why I tried using createSQLQuery function, however it requires specyfing return class. What class should I use? I was trying different combinations, for example:

Code:
session.createSQLQuery("select CURRENT_TIMESTAMP {time}", "time", GregorianCalendar.class).list()


however it gives following exception:

Code:
net.sf.hibernate.MappingException: No persister for: java.util.GregorianCalendar


This seems strange to me as I don't have to map library classes.

I suppose the solution is straightforward and it's just my incompetence that causes problems :)

Help! :)
julius


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 25, 2004 1:41 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Use JDBC connection to execute this query. 'session.connection() ... '


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