Hi Friends,
I am trying to retrieve objects from database which are created in between two given dates.
I tried following query but
no result and no exception, empty iteratator is returned by the query.list() method:
Code:
challans = session.createQuery("select h from ChallanPO as h where CUSTOMERID="+custID+" AND CREATIONDATE > "+"2008-10-1"+" AND CREATIONDATE < "+"2009-3-31").list();
ChallanPO stores date reference of type java.util.Date object.
and in database column CREATIONDATE is of type DATETIME.
Hibernate version:3.1
Name of the database you are using: mySql
[b]The generated SQL (show_sql=true):[br]
Hibernate: /* select h from ChallanPO as h where CUSTOMERID=1.0 AND CREATIONDATE > 2008-10-1 AND CREATIONDATE < 2009-3-31 */ select challanpo0_.CONSIGNMENT_ID as CONSIGNM1_4_, challanpo0_.CUSTOMERID as CUSTOMERID4_, challanpo0_.NOOFJOBS as NOOFJOBS4_, challanpo0_.DESTINATION as DESTINAT4_4_, challanpo0_.CREATIONDATE as CREATION5_4_, challanpo0_.SOURCE as SOURCE4_, challanpo0_.VEHICLE_NUMBER as VEHICLE7_4_, challanpo0_.CARRIER_ID as CARRIER8_4_, challanpo0_.INVOICE_ID as INVOICE9_4_, challanpo0_.ISINVOICED as ISINVOICED4_, challanpo0_.TAXAMOUNT as TAXAMOUNT4_, challanpo0_.TAXPERCENTAGE as TAXPERC12_4_, challanpo0_.VAT as VAT4_, challanpo0_.SUBTOTAL as SUBTOTAL4_, challanpo0_.GRANDTOTAL as GRANDTOTAL4_, challanpo0_.PAYMENTSTATUS as PAYMENT16_4_ from consignment challanpo0_ where CUSTOMERID=1.0 and CREATIONDATE>2008-10-1 and CREATIONDATE<2009-3-31
[b]
Please suggest.