-->
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: Query.list() - Reporting Query get result as a Map
PostPosted: Wed Jan 26, 2005 4:41 pm 
Newbie

Joined: Wed Jan 26, 2005 2:03 pm
Posts: 1
Hibernate version: 2.1.7

Name and version of the database you are using: MySQL 4.0.18

Hello,

i'm looking for a way to get the result of a reporting query as
an associative array.

Example in Pseudocode:
Code:
// a, b, c - properties of objects - not entities
Query q = hibernateSession.createQuery("SELECT a,b,c FROM x JOIN Y");
List results = q.list();
...
while (moreResults) {
    result = (Object[]) it.next();
    String a   = (String) result[0];
    Integer b = (Integer) result[1];
    ...
}


This way code is likely to get errorprone. Is there a way to get as result
a Map - so that the result can be accessed as an associative array?

Code:
    // nicer would be something like
    String a   = result.getString("a);
    Integer b = result.getInteger("b");


Any ideas?

Thanks,
Stefan.


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.