-->
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: returning a collection of maps from a query
PostPosted: Fri Apr 01, 2005 12:02 pm 
Newbie

Joined: Thu Mar 17, 2005 12:10 am
Posts: 8
Is there a way to return a collection of maps rather than a collection of Object arrays in Hibernate when using queries that contain aggregation functions?

For example:

select sum(rc.score) as totalScore from ReportCard rc

As an object array you have to refer to the result by index. But if it were a map, you could refer to it by column name (eg. map.get("totalScore")). This would provide similar to JDBC ResultSet objects. I don't like having to know what column maps to what index and I don't want to create a customized object to encapsulate my results (i.e Select new Result(sum(rc.score))).

So, is it possible to get a collection of maps?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 12:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There is an existing JIRA issue for this somewhere.

I proposed the syntax:

select new Map(....) from .....

If you want to try implementing this, that would be cool (should be fairly straightforward with new query parser in HB3).


Note that for the Criteria API, you *can* do this, using the ResultTransformer stuff.


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.