I am running the following query, I get a list size of 160. How do I cast the objects returned to date type, I get an exception
Regards,
Vinaypal
Hibernate version:2.1.8
[b]Mapping documents:
Named Query
<sql-query name="NonJaguarEligibleStartAndEndDate"> select eligible_from,eligible_to from common.vehicle_eligible ve, common.vehicle_year vy where vy.numeric_year = ve.model_year and ve.program_code = :programCode </sql-query>
Code between sessionFactory.openSession() and session.close():[
Session s = getSession(); Query q = (Query)s.getNamedQuery ("NonJaguarEligibleStartAndEndDate");
q.setString("programCode", "100"); List retList = q2.list(); if (retList != null) { System.out.println("NonJaguarEligibleStartAndEndDate size-- " + retList.size()); Object[] row = (Object[]) retList.get(10); Date start = (Date) row[0]; Date end = (Date) row[1]; FOPPSession.logInfo(start.toLocaleString());
} else { System.out.println("NULL"); }
/b]
[b] Exception:
NonJaguarEligibleStartAndEndDate -- 160 java.lang.ArrayIndexOutOfBoundsException: 0 at com.ma.fopp.service.dao.hibernate.FOPPValidatorHibernateDAO.getNonJaguarEligibleStartAndEndDates(FOPPValidatorHibernateDAO.java:269) at com.ma.fopp.service.spring.FOPPValidatorServiceSpringImpl.validateVINSaleDate(FOPPValidatorServiceSpringImpl.java:132) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:284) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:163) at $Proxy3.validateVINSaleDate(Unknown Source) at com.ma.fopp.actions.validation.FOPPSaleDateValidateAction$FOPPSaleDateValidationThread.run(FOPPSaleDateValidateAction.java:194) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
Name and version of the database you are using: Oracle 8i
The generated SQL (show_sql=true):
select eligible_from,eligible_to from common.vehicle_eligible ve, common.vehicle_year vy where vy.numeric_year = ve.model_year and ve.program_code = ?
Debug level Hibernate log excerpt:
|