ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: Question on dynamic Select Columns
Date Fri, 27 May 2005 12:55:20 GMT
Hey Ritu,

The dynamic tags examine the parameterMap or parameterClass not the
resultMap. Also, since your select results will potentially differ you
will need to set the remapResults="true" attribute in the <select>.

Brandon

On 5/27/05, Ritu Kedia <ritu.kedia@mphasis.com> wrote:
>  
>  
> 
> Hello All, 
> 
>   
> 
> This is my first post to IBatis. We are planning to use IBatis as our
> OR-Mapping tool. 
> 
>   
> 
> First of all thanks to all the contributors for this great contribution. I
> particularly liked the dynamic SQl feature. 
> 
>   
> 
> I have a question on whether the select columns can also be made dynamic?
> Currently I am getting SQLException for Invalid Column Name when the
> framework is trying to map the fetched data to the declared Result Map. 
> 
>   
> 
> OR Could we bind the ResultMap dynamically to the Select statement? In other
> words could we have something like: 
> 
>       <select id="FindDynamic" resultMap="$resultMap$"> 
> 
>             SELECT      ID, 
> 
>                         NAME 
> 
>             <dynamic prepend=","> 
> 
>                   <isNotNull property="fetchDetails"> 
> 
>                         DESCRIPTION, 
> 
>                   </isNotNull> 
> 
>             </dynamic> 
> 
>             FROM  SOME_TABLE 
> 
>             <dynamic prepend="WHERE"> 
> 
>                   <isNotNull prepend="AND" property="name"> 
> 
>                         NAME $name_operator$ #name# 
> 
>                   </isNotNull> 
> 
>                   <isNotNull prepend="AND" property="description"> 
> 
>                         DESCRIPTION $description_operator$ #description# 
> 
>                   </isNotNull> 
> 
>             </dynamic>        
> 
>       </select> 
> 
> Where $resultMap$ would be passed via the Java API. 
> 
>   
> 
> If the resultMap is hard bound to the following: 
> 
>       <resultMap id="Detail_ResultMap" class="Some_Detail"> 
> 
>             <result property="name" column="Name"/> 
> 
>             <result property="description" column="Description"/> 
> 
>             <result property="id" column="ID"/> 
> 
>       </resultMap> 
> 
>   
> 
> In the above select if the resultMap="Detail_ResultMap" then when property
> "fetchDetails" is not present then I get a SQLException "Invalid Column
> Name" for the Description column. 
> 
>   
> 
> Could someone please suggest a way to accommodate the above requirement of
> having dynamic select columns? 
> 
>   
> 
> Thanks and Regards, 
> 
> Ritu Kedia

Mime
View raw message