-->
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: Order By Value in Map of List of Map of etc
PostPosted: Fri Mar 18, 2011 7:53 am 
Beginner
Beginner

Joined: Tue Nov 02, 2010 4:29 am
Posts: 21
I have a persisted object with a map field that can stores key values pairs.
The value in each pair can also be another map of the same type or a list or a value.
The list can also contain maps, list or other values.
The list, map and value classes all share a common abstract superclass which is the class type for values in the list and map.
This all provides a tree like structure for storing arbitrary meta data.
I would like to order on the value of a node in the tree, e.g. a.b.c (where e.g. a is the map, b is a list and c is a value) which is present for some but not all objects of that class, but it is present for all objects in the result set (by nature of a common parent object).
I currently have to read all the objects into a collection and sort the collection with a customer comparator (in Java code) but I was wondering if there was a way to do the ordering on the database?


Top
 Profile  
 
 Post subject: Re: Order By Value in Map of List of Map of etc
PostPosted: Tue Mar 22, 2011 12:19 pm 
Beginner
Beginner

Joined: Tue Nov 02, 2010 4:29 am
Posts: 21
I was wondering if a two pass approach is the correct way - one which gets the ids of the parent class (sorted according to the associate value) and then another query that returns the parent classes in a list?


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.