ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Langer <mailtolan...@googlemail.com>
Subject Re: Is it possible to have an optional property in resultMap?
Date Thu, 15 Mar 2007 16:04:08 GMT
Collin Peters schrieb:
> Hi everyone,
>
> I'm just wondering if it is possible to have an optional property in a
> resultMap?  For example, I have a UserVO class which I use to load
> users into.  It has fields such as user_id, username, firstname,
> lastname, password, etc...  I also want to use this class as a
> 'sub'-resultMap from another call.  For example, I have a call called
> loadDailySchedule, in this call I grab all events in a schedule, along
> with all the participants, and group by the event_id.  So the sqlmap
> is:
>
>     <resultMap id="eventResult" class="EventVO" groupBy="eventID">
>         <result property="eventID" column="event_id" />
>         <result property="summary" column="summary" />
> <snip...>
>         <result property="participants" resultMap="common.userResult" />
>     </resultMap>
>
> The problem is that I don't want to have to include fields like the
> users password in this query as it is not needed.  If I want to use
> the common.userResult resultMap (which uses the UserVO class) though,
> I need to include those fields otherwise I get the error: "The column
> name password was not found in this ResultSet"
>
> Regards,
> Collin
>
You could build a result hierarchy so that userResult and eventResult 
inherit their common field from a resultmap abstractUserResult or the like.

Hope I made myself clear

Stefan

Mime
View raw message