ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ritu Kedia" <ritu.ke...@mphasis.com>
Subject Question on dynamic Select Columns
Date Fri, 27 May 2005 06:08:22 GMT
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,


            <dynamic prepend=",">

                  <isNotNull property="fetchDetails">




            FROM  SOME_TABLE

            <dynamic prepend="WHERE">

                  <isNotNull prepend="AND" property="name">

                        NAME $name_operator$ #name#


                  <isNotNull prepend="AND" property="description">

                        DESCRIPTION $description_operator$ #description#




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"/>



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

View raw message