-->
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.  [ 3 posts ] 
Author Message
 Post subject: Return result of query as HashMap
PostPosted: Mon Sep 07, 2009 4:25 pm 
Newbie

Joined: Mon Sep 07, 2009 4:20 pm
Posts: 12
Hello,

I am quite new to hibernate and wonder if it is possible to make a Query return the result as a HashMap which would look as in this example...:

HashMap<String, String> h new HashMap<String, String>();
h.put("en", "English");

Is this possible, or is there maybe a better way to achieve this?

Best regards


Top
 Profile  
 
 Post subject: Re: Return result of query as HashMap
PostPosted: Mon Sep 07, 2009 8:40 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Your queries will return Lists, Sets, or potentially arrays of objects.

What are you trying to achieve and why? Maybe with more info we can find an alternate way.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Return result of query as HashMap
PostPosted: Thu Sep 10, 2009 2:52 pm 
Newbie

Joined: Mon Sep 07, 2009 4:20 pm
Posts: 12
Hi there and thanks for your answer!

I was thinking of a hashmap to be able to access a record from the query result by it's primary key, ("en" in my example), and not by it's index in the list (would be "0" in my example).

At the end I might be able to resolv what I want to do using an sql join, I'm still investigating...


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