-->
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: How to retrieve data about date and time?
PostPosted: Sun Aug 01, 2004 5:58 am 
Newbie

Joined: Sun Aug 01, 2004 5:43 am
Posts: 1
In SQL Statement, we can use some date and time function that are different in different database system. For example, in SQL Server 2000,
datediff and dateadd.
I can use a SQL in hibernate but if I do like that My codes can't be applied to different database. The purpose of hibernate is to make the databases no difference in java developers' eyes. So I think it should encapsulate this just like it user Expression class to encapsulate some
query condition such as eq, like. But I can't know how to deal with query
about date and time. Help!
Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 3:13 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
What date and time functions do you need? If you are talked about date/time formatting functions, use following approach:
Code:
List result = session.createQuery("from MyClass obj where obj.someDate > ?")
    .setParameter(0, new Date(), Hibernate.DATE)
    .list();

you also could use Hibernate.TIME and Hibernate.TIMESTAMP.
So you don't need any date/time formatting fuctions :)

--
Leonid


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.