-->
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.  [ 1 post ] 
Author Message
 Post subject: Want IList of IDictionary instead of IList of object[]
PostPosted: Mon Nov 07, 2005 4:33 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Often I will want a query that selects from multiple entities to be displayed in a DataGrid. However, I don't want my query to be

SELECT a.Column1, b.Column2, c.Column3, ...
FROM mainEntity a
JOIN relatedEntity1 b,
JOIN relatedEntity2 c, ...

because then I won't get entities back -- I want entities rather than raw values, so that the user can right-click on a grid column and do something with the entity that the column belongs to.

However, if I instead do only

FROM mainEntity a,
JOIN relatedEntity1 b,
JOIN relatedEntity2 c, ...

then I need to know that in the object array returned, the 1st item is a, the 2nd item is b, the 3rd item is c, etc. This is unsatisfactory because I want to be able to specify what entities are being queried, and which properties from those entities to display, independently of each other. Most likely, I will want an option for the user to right-click on the grid header and select "Choose columns" from a context menu at runtime, and properties will be bound/unbound to the grid.

So, I'd like to get an IList of IDictionaries back from the query, instead of just an IList of object[]. Each dictionary would be keyed by the alias used in the query. That way, I can use the aliases from the query to pick which properties to bind to the grid, instead of keeping track of the index numbers of the selected entities.

Of course I could try to convert each object[] into an IDictionary myself, but then I'd have to write an HQL parser to figure out what the aliases are for an arbitrary HQL statement ...

p.s. Since the number of different entities returned by a query would almost certainly be less than 10, the IDictionaries returned should be of type ListDictionary rather than Hashtable ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.