ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Transform List resultmap to Map
Date Thu, 05 Oct 2006 14:08:22 GMT
There are several things you could do here.

Instead of mapping the child results in the config, you could step
through the parent list and use queryForMap() in the dao to populate
the child maps.

You could leave the config as is and walk through the lists and turn
them into maps, that would work ok, and if there are not a ton of
results, that might be easiest.

You could use groupby to do this all in one SQL statement, then walk
through the lists and turn them into maps, which would probably be the
most work, but I think you'd get the better performance that way.

Or you could use a rowhandler and do the object creation
yourself..that would be even more work, but I think you would get the
top performance with that.

Larry


On 10/5/06, Javier Leyba <xleyba@gmail.com> wrote:
> Hi
>
> In my application I´m calling a query that includes a join and return
> a result to a resultMap wich has a field that holds a List with other
> resultMap, like this:
>
> ---------------
>     <resultMap id="notificationListResult" class="notification">
>                 <result property="id" column="id" />
>                 <result property="topicId" column="topic_id" />
>                 <result property="sourceTypeId" column="source_type_id" />
>                 <result property="notificationTypeId"
>                         column="notification_type_id" />
>                 <result property="category" column="category" />
>                 <result property="priority" column="priority" />
>                 <result property="source" column="source" />
>                 <result property="expiration" column="expiration"
>                         javaType="java.util.Date" />
>                 <result property="notificationDescription"
>                         resultMap="Notification.notificationDescriptionListResult" />
>         </resultMap>
>
>         <resultMap id="notificationDescriptionListResult"
>                 class="notificationDescription">
>                 <result property="notificationId" column="id" />
>                 <result property="topicId" column="topic_id" />
>                 <result property="sourceTypeId"
>                         column="source_type_id" />
>                 <result property="notificationTypeId"
>                         column="notification_type_id" />
>                 <result property="locale" column="description_locale" />
>                 <result property="title" column="title" />
>                 <result property="description" column="description" />
>         </resultMap>
>
> --------------
>
>
> It work well but I´m having problem with List and I wonder if could I
> make a custom class or something else to transform
> notificationListResult.notificationDescription from List to Map before
> return the final List of objects to my app.
>
> Also, I would like to know if there is a plan to allow iBatis to
> accept Maps instead of List.
>
> Thanks in advance
>
> J
>

Mime
View raw message