Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate return groups of sorted objects

 
Raymond Holguin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way in hibernate i can query and return the results grouped together by a a certain value, maybe in a List of Arrays or something like that?

i know its kind of hard to explain but if i queried and got a result like this.
[[1,1,1],[3,3,3],[6,6,6]]

the number is just the property Im querying but it would actually be the Object not just the value. So i would have like a Array where each element is an array of objects of that same value. The reason im doing it this way is because in my app I need to return sets of data in groups like this, but the groups also need to be sorted by multiple columns and i want to handle as much as I can in SQL rather than code.

I know i could just do a "sort-by" property X, loop through the result list and manually group them in my own array structure. but like i said the more i can handle in the SQL the better.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic