This content has been marked as final.
Show 4 replies
-
1. Re: Why does EJB QL between not work?
epbernard Oct 28, 2005 4:49 PM (in response to jbosschecker)Hum, I already answered the same question somewhere. Guys try not to crosspost.
-
2. Re: Why does EJB QL between not work?
jbosschecker Oct 29, 2005 6:26 AM (in response to jbosschecker)Thanks for your response.
I had to answer the question, because nobody answered to it.
Sorry.
I have tried to build date objects with the GregorialCalendar like this:Calendar c = new GregorianCalendar() c.set(paramYear, 1, 1); java.util.Date start = c.getTime(); c.set(paramYear, 12, 31); java.util.Date end = c.getTime();
and here is my query:Query q = manager.createQuery("from Order o where o.orderDate netween start and end"); q.setParameter("start", start); q.setParameter("end", end); ...
but it doesn't work! -
3. Re: Why does EJB QL between not work?
epbernard Nov 4, 2005 5:06 AM (in response to jbosschecker)q.setParameter("start", start, TemporalType.DATE);
-
4. Re: Why does EJB QL between not work?
martinganserer Nov 23, 2005 9:37 AM (in response to jbosschecker)Hello,
I have the same problem. Please take a look at my code:Calendar startDate = new GregorianCalendar(2005,1,1); Calendar endDate = new GregorianCalendar(2005,1,1); // Set range of twelve month endDate.add(GregorianCalendar.MONTH,12); System.out.println(endDate.get(Calendar.DATE) + "." + endDate.get(Calendar.MONTH) + "." + endDate.get(Calendar.YEAR)); buf.append("select distinct o from CustomerOrder o join o.lineItems l "); buf.append("where (l.wantedDeliveryDate >= :paramStartDate "); buf.append("and l.wantedDeliveryDate < :paramEndDate) "); buf.append("and o.enteredBy = :paramSalesMan "); Query query = em.createQuery(buf.toString()); query.setParameter("paramStartDate",startDate,TemporalType.DATE); query.setParameter("paramEndDate",endDate,TemporalType.DATE); query.setParameter("paramSalesMan",salesMan);
I can execute the query. But I do not get the proper resultset. What should I do?
I have already tried to use Date instead of Calendar. And I have even tried the between operator. I always get more records than I expect!
Thank you!