-->
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.  [ 3 posts ] 
Author Message
 Post subject: sqlQuery select dates between
PostPosted: Thu Jun 30, 2005 8:07 am 
Beginner
Beginner

Joined: Wed Feb 23, 2005 10:37 am
Posts: 29
Hi,

I am trying to do the following.

Code:
List ids=HibernateUtil.currentSession().createSQLQuery(select id as {act.actID} from activationdate act where act.act_date between to_date('14.07.2005','dd.mm.yyyy') and to_date('20.07.2005','dd.mm.yyyy')
.addEntity("act", ActID.class)
.list();

Which works fine.

Is it possible to set these dates as named parameters?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 30, 2005 9:06 am 
Beginner
Beginner

Joined: Wed Feb 23, 2005 10:37 am
Posts: 29
one solution would be:
Code:
List ids=HibernateUtil.currentSession().createSQLQuery(select id as {act.actID} from activationdate act where act.act_date >=:fromDate and
act.act_date<=toDate
.addEntity("act", ActID.class)
.setCalendar("fromDate",fromInd)
.setCalendar("toDate",toInd)
.list();


Is there any other (better) way of doing that?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 30, 2005 9:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what is the problem with the suggested one ? and why not just use "between :fromDate to :toDate" ?

_________________
Max
Don't forget to rate


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