-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Re: Urgent Please Help regarding Query return type
PostPosted: Mon Mar 28, 2005 12:14 pm 
Newbie

Joined: Fri Mar 18, 2005 9:10 am
Posts: 6
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:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 28, 2005 9:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Your returning two dates per- data line. So the returned data is a List of arrays with two elements that are both dates.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.