-->
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: Problem with Date HQL
PostPosted: Fri Nov 02, 2007 5:20 pm 
Newbie

Joined: Sat Oct 27, 2007 12:32 pm
Posts: 2
Hi Im trying to figure out what's wrong with this query

" from terminals te where te.creationDate between " + creationDateInit + " and " + creationDateEnd


When I run this query i got an error
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: Nov


The query translates something like this

te.creationDate between Mon Nov 26 00:00:00 GMT 2007 and Thu Nov 29 23:59:59 GMT 2007

Any Idea??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 02, 2007 8:58 pm 
Newbie

Joined: Wed Oct 31, 2007 5:36 pm
Posts: 13
Your query string becomes a string literal after the toString() is executed on the date objects.

You should do something like this:

Code:
String hql = "from terminals te where te.creationDate between :start and :end";

List results = session.createQuery(hql).setTimestamp("start", creationDateInit).setTimestamp("end", creationDateEnd).list();


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.