-->
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.  [ 1 post ] 
Author Message
 Post subject: How to get value in hashmap or array for complex hql query
PostPosted: Fri May 29, 2009 3:24 am 
Newbie

Joined: Fri May 29, 2009 3:13 am
Posts: 1
Hello Users,

I need you help in following.

I am developing my application in hibernate 3 and struts 2 framework.

I have following query.

I have 3 tables

1. Inspection
2. InspectionMission
3. Timeline

Inspection is associated with InspectionMission and InspectionMission is associated with Timeline.

Now I have following problem. I have written following query in HQL


public List getQuartewiseInspectionList(){

Session session = HibernateUtil.getSessionFactory().getCurrentSession();

Query q = session.createQuery(
"select count(i.inspectionId) as tot_inspections,t.year,t.quarter" +
" From Inspection as i " +
" inner join i.inspectionMission as im inner join im.timeline as t" +
" GROUP by t.year,t.quarter");

return q.list();

}

Now I want result of above query in following format of array or hashmap
result[0][tot_inspections] = 3
result[0][year] = 2009
result[0][quarter] = q2

result[1][tot_inspections] = 6
result[1][year] = 2009
result[1][quarter] = q3

and so on..

So that in struts I can access result using struts iterator as following

<table border="1">

<s:iterator value="result" status="status">
<tr class="<s:if test="#status.even">even</s:if><s:else>odd</s:else>">
<td class="nowrap"><s:property value="tot_inspections" /></td>
<td class="nowrap"><s:property value="year" /></td>
<td class="nowrap"><s:property value="quarter" /></td>
</tr>
</s:iterator>
</table>

How can I do that? Can anyone please help.

Thanks.


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

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.