-->
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.  [ 6 posts ] 
Author Message
 Post subject: Comparing times?
PostPosted: Fri Nov 21, 2003 11:10 am 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
I'd like to get all Objects that have a Calendar/Date-Element which is older then the actual time.
I'm using the following line right now:

this.getSession().delete("from MyElt where OBJTIME < now");


the mapping is:
...
<property name="objTime" column="OBJTIME" type="calendar"/>
...


My call works fine with my hsql database, because it knows about the "now"-String and replaces it with the current date.

Is there a way to make my this.getSession().delete(...)-String independent from the database-type?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 11:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
from MyElt e where e.ojbTime < now


Top
 Profile  
 
 Post subject: now won't work?
PostPosted: Fri Nov 21, 2003 12:24 pm 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
Quote:
from MyElt e where e.ojbTime < now


Well, my problem is that I think, that the expression "now" won't work because this is just a special keyword in hsql...
Isn't there a way to compare the times without using "now"?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 12:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ummm. Do you realize that I write most of Hibernate?

I have a pretty fair idea of what works.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 12:44 pm 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
Quote:
Ummm. Do you realize that I write most of Hibernate? I have a pretty fair idea of what works.


I'm sorry. I did not want to doubt this. I just thought that the now-function was database-specific.

I'm sorry, this was obviously my fault.

Thanks for the help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 12:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is database specific. If you need to abstract SQL functions from multiple databases, you need to use hibernate.query.substitutions. We've discussed in the dev list that it is kinda impractical to try to abstract all SQL functions (though in future we might go for an abstraction layer for just the ANSI standard functions like current_date).


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