-->
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: return an hashmap from a sql named query
PostPosted: Sat Jul 09, 2011 9:00 am 
Newbie

Joined: Sat Jul 09, 2011 8:54 am
Posts: 1
I have this sql query
Code:
<sql-query name="getStudentNameAndAddressStreet"  >     
      select s.STUDENT_NAME as student_name, a.ADDRESS_STREET as address_street
      from STUDENT s , ADDRESS a
      where s.STUDENT_ADDRESS = a.ADDRESS_ID
   </sql-query>


Now it return an object[], and I cicle it :

Code:
List<Object[]> resList = session.getNamedQuery("getStudentNameAndAddressStreet" ).list();
         
         for (Object[]  row: resList) {
            System.out.println(  row[0] + " "+ row[1] );
            }


I'd like have an hashmap so I'll can:

Code:
List  resList = session.getNamedQuery("getStudentNameAndAddressStreet" ).list();
         
         for (HashMap row: resList) {
            System.out.println(  row.get("student_name") + " "+ row.get("address_street")  );
            }


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.