-->
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.  [ 6 posts ] 
Author Message
 Post subject: hibernate returns list , can it return Map
PostPosted: Wed Mar 02, 2011 3:22 pm 
Newbie

Joined: Fri Feb 25, 2011 2:34 am
Posts: 11
hi friends,
I am developing an application in struts2 and hibernate and i dont like the list returned by hibernate create query function on session,
actually if i tie the list to a variaable and access in jsp then i have to rely on object index rather than name,
It is becoming complicated to remember the index of the list variable,
Is there any other way out
Pl. help,
abhishek


Top
 Profile  
 
 Post subject: Re: hibernate returns list , can it return Map
PostPosted: Wed Mar 02, 2011 11:09 pm 
Newbie

Joined: Mon Jan 31, 2011 11:22 pm
Posts: 6
I don't think you can. What would you want the key to be if you were to use a map?


Top
 Profile  
 
 Post subject: Re: hibernate returns list , can it return Map
PostPosted: Thu Mar 03, 2011 1:56 am 
Newbie

Joined: Fri Feb 25, 2011 2:34 am
Posts: 11
I want the key to be the column name.

abhi


Top
 Profile  
 
 Post subject: Re: hibernate returns list , can it return Map
PostPosted: Thu Mar 03, 2011 2:05 am 
Regular
Regular

Joined: Fri Nov 12, 2010 4:13 am
Posts: 81
Location: India
SQLQuery queryResult = session.createSQLQuery("Select * from xyz");

queryResult.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);

This will return you a Map.

Try this out

_________________
Thanks & Regards,
Chirag


Last edited by chirag.naikec on Thu Mar 03, 2011 2:14 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: hibernate returns list , can it return Map
PostPosted: Thu Mar 03, 2011 2:08 am 
Newbie

Joined: Fri Feb 25, 2011 2:34 am
Posts: 11
no, i dont think so,
each row will have its own unique pair and so on.
Actually this will allow the jsp coders to work independently of knowing which index the data lies in.

thanks

abhi


Top
 Profile  
 
 Post subject: Re: hibernate returns list , can it return Map
PostPosted: Thu Mar 03, 2011 2:15 am 
Regular
Regular

Joined: Fri Nov 12, 2010 4:13 am
Posts: 81
Location: India
ejaincom wrote:
no, i dont think so,
each row will have its own unique pair and so on.
Actually this will allow the jsp coders to work independently of knowing which index the data lies in.

thanks

abhi


SQLQuery queryResult = session.createSQLQuery("Select * from xyz");

queryResult.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);

This will return you a Map.

Try this out

_________________
Thanks & Regards,
Chirag


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.