-->
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: "between" query returns different result!
PostPosted: Fri Jan 06, 2006 7:16 am 
Newbie

Joined: Tue Sep 06, 2005 9:50 am
Posts: 13
Hibernate version: 2.1.8
Hi all,

I have a small problem. I'm generating an Query string which contains the following:
Code:
String queryString = "from News n where n.status = :status AND :date between n.publicationDate AND n.expirationDate";

As you can see I'm using named parameters, where :date = new Date() we can discard :status in this case.
I'm using oracle 9.2 database in the background to retrieve the data. It seems that every database has its own way of dealing with the "between" actions. But that aside...
When I execute the sql query directly in oracle, I get different results (:date is replaced by sysdate). If the expirationDate is :date, the records are excluded in oracle, but included in hibernate Query!?
What's going wrong/different?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 8:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No clue - Hibernate just sets your parameter in a normal JDBC prepared statement. Probably some strange Oracle issue.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 3:57 am 
Newbie

Joined: Tue Sep 06, 2005 9:50 am
Posts: 13
Is there a way to rewrite my query string?

Maybe in the order of:
Code:
:date after publicationDate and :date before expirationDate


The publicationDate and expirationDate fields are also date type fields.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 4:51 am 
Newbie

Joined: Tue Sep 06, 2005 9:50 am
Posts: 13
I fixed it by using >= and < signs in stead of between command. ;-)


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.