Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

date comparison not working in EJB3  RSS feed

 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
select ds from DSchedule ds where ds.scheduledDate <= :upperBoundDate

now this query does not reurn values....very strange....but there are records into the database.

I am passing upperBoundDate as calendar innstance...

Please tell me where I am making wrong???

Thanks in advance.

Rahul.
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show how you used Query#setParameter.
 
Rahul Ba
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Query getDistributionSchedulesByDate = entityManager.createNamedQuery("getDistributionSchedulesByDate");

getDistributionSchedulesByDate.setParameter("upperBoundDate", DateUtils.getUpperBoundDate(date));


List<DistributionSchedule> resultList = (List<DistributionSchedule> getDistributionSchedulesByDate.getResultList();
**********************************

And DateUtils.getUpperBoundDate(date) method implementation is like::

public static Calendar getUpperBoundDate(Calendar date) {

Calendar upperBoundDate = Calendar.getInstance();
upperBoundDate.setTime(date.getTime());

upperBoundDate.set(Calendar.HOUR_OF_DAY, 23);
upperBoundDate.set(Calendar.MINUTE, 59);
upperBoundDate.set(Calendar.SECOND, 59);

System.out.println(upperBoundDate.getTime());

return upperBoundDate;
}
[ November 06, 2008: Message edited by: Rahul Ba ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, the year/month/day you are passing to getUpperBoundDate is higher than the dates you have in your DB ?
Another thing, how did you define DSchedule#scheduledDate ?

If you're still having problems, you may try to use the following instead :
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!