Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • 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
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

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 :
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!