Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

date comparison not working in EJB3  RSS feed

 
Rahul Ba
Ranch Hand
Posts: 212
  • 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.
 
Christophe Verré
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: 212
  • 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 :
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!