• 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

date comparison not working in EJB3  RSS feed

 
Ranch Hand
Posts: 215
  • 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: 215
  • 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!