-->
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: Wrap a native query result into a list of maps.
PostPosted: Wed Mar 08, 2006 6:43 pm 
Newbie

Joined: Wed Oct 06, 2004 10:34 am
Posts: 16
Location: Teresina - PI - Brasil
How could I wrap a native sql query into a map using new map?

I would like to create named native queries and their results should be returned in map collection datasources for use in reports.

I would like to use something like the following example:

Code:
<sql-query name="findPerson">
   SELECT new map(p.ID AS id, p.NAME AS name)
   FROM PERSON p
</sql-query>


Of course this is a simple example that could be easily done with HQL.
But I have many complex SQL queries already done that I want to migrate to Java using Hibernate.

Now I use something like this:

Code:
<sql-query name="findPerson">
   <return-scalar column="id" type="int"/>
   <return-scalar column="name" type="string"/>

   SELECT new map(p.ID AS id, p.NAME AS name)
   FROM PERSON p
</sql-query>


The problem is that I have to iterate over the resulting list to convert each element to a Map and add them to a new list.

So, can I use new map with native queries? Any other suggestion?

_________________
Regis Pires


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.