• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

date comparison not working in EJB3

 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show how you used Query#setParameter.
 
Rahul Ba
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :
 
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic