title: java.lang.ClassCastException: String can't be cast to Date
body: <h2>Stacktrace:</h2>
  
  <pre><code>java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
          at org.hibernate.type.descriptor.java.JdbcTimestampTypeDescriptor.unwrap(JdbcTimestampTypeDescriptor.java:41)
          at org.hibernate.type.descriptor.sql.TimestampTypeDescriptor$1.doBind(TimestampTypeDescriptor.java:65)
          at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:90)
          at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:286)
          at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:281)
          at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:67)
          at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:613)
          at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1900)
          at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1861)
          at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
          at org.hibernate.loader.Loader.doQuery(Loader.java:909)
          at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
          at org.hibernate.loader.Loader.doList(Loader.java:2553)
          at org.hibernate.loader.Loader.doList(Loader.java:2539)
          at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369)
          at org.hibernate.loader.Loader.list(Loader.java:2364)
          at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
          at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
          at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)
          at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
          at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
          at com.nutsaboutcandywebproject.dao.SQLOrdersDataAccess.getMonthlyReport(SQLOrdersDataAccess.java:129)
          at com.nutsaboutcandywebproject.service.ServiceFacadeImpl.getOrdersPerMonth(ServiceFacadeImpl.java:127)
          at com.nutsaboutcandywebproject.controller.OrderController.orderHistory(OrderController.java:237)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
          at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
          at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690)
          at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
          at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
          at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:724)
  </code></pre>
  
  <h2>Code:</h2>
  
  <pre><code>@Override
      public List &lt;Orders&gt; getMonthlyReport(String date){
  
          Session session = HibernateUtil.getSessionFactory().openSession();
          Transaction transaction = session.beginTransaction();
  
          String hqlQuery = "FROM Orders WHERE orderDate LIKE :orderDate AND orderStatus = :orderStatus";
          Query query = session.createQuery(hqlQuery);
          query.setParameter("orderDate", date+"%");
          query.setParameter("orderStatus", "PENDING");
  
          List&lt;Orders&gt; orderList = query.list();
  
          transaction.commit();
          session.close();
          return orderList;
      }
  </code></pre>