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: Is it possible to have an optional property in resultMap?
Date Thu, 15 Mar 2007 17:19:33 GMT
You could use dynamic SQL to do that, just make the password '' in the
cases you don't want it.

select ...
<isEqual property="showPassword" compareValue="true">password</isEqual>
<isEqual property="showPassword" compareValue="false">'' as password</isEqual>


On 3/15/07, Collin Peters <cadiolis@gmail.com> wrote:
> 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

View raw message