You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by ramy <ra...@gmail.com> on 2007/10/18 20:19:24 UTC

passing a list to sqlmap

I have a list over which the select statement has to be run 
my sql is like 

<select id="selectAssgnResults"  parameterClass="java.util.List"
  
    resultMap="RschResult" >
    select     
    <iterate  property="reportData" open=" " close=" " conjunction=","> 
      $[]$
     
     </iterate>
    
       from RSCH
    
  </select>


It throws me an error 

--- Check the selectAssgnResults.  
--- Check the parameter map.  
--- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
list from JavaBean. Cause java.lang.StringIndexOutOfBoundsException: String
index out of range: -1

-- 
View this message in context: http://www.nabble.com/passing-a-list-to-sqlmap-tf4648784.html#a13280522
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: passing a list to sqlmap

Posted by ramy <ra...@gmail.com>.
Larry,
I tried the remapResults="true"

<select id="selectAssgnResults" parameterClass="java.util.List"  
remapResults="true" >
     select  
    <iterate  open=" " close= " " conjunction=","> 
     #ll[]#  </iterate>
     from  RSCH    
    </select>

now i dont get any error but the query doesnt return any results as well.ls
it the property too has to be specified or it takes them from the list and
maps them to the resultmap and if i have to map the property to then that
wud be like  
<iterate  open=" " close= " " conjunction="," property="ll"> 
     #ll[]#  </iterate> 
 which wud again given an indexOutOfBounce exception

please let me know as i am going nowwhere


ramy wrote:
> 
> I have a list over which the select statement has to be run 
> my sql is like 
> 
> <select id="selectAssgnResults"  parameterClass="java.util.List"
>   
>     resultMap="RschResult" >
>     select     
>     <iterate  property="reportData" open=" " close=" " conjunction=","> 
>       $[]$
>      
>      </iterate>
>     
>        from RSCH
>     
>   </select>
> 
> 
> It throws me an error 
> 
> --- Check the selectAssgnResults.  
> --- Check the parameter map.  
> --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
> list from JavaBean. Cause java.lang.StringIndexOutOfBoundsException:
> String index out of range: -1
> 
> 

-- 
View this message in context: http://www.nabble.com/passing-a-list-to-sqlmap-tf4648784.html#a13285312
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: passing a list to sqlmap

Posted by ramy <ra...@gmail.com>.
ive done like 
<select id="selectAssgnResults"   
    resultMap="RschResult" parameterClass="java.util.List" >
     select     
    <iterate   open=" " close=" " conjunction=","> 
     #ll[]#</iterate>
     from RSCH    
    </select>

and now it comments on the resultmap saying ivalid column name 

--- Check the result mapping for the 'trackingIdC' property.  
--- Cause: java.sql.SQLException: Invalid column name


you mean to build the query in java itself intsead of doing it here in the
sqlmap?

Regards
ram



Larry Meadors-2 wrote:
> 
> you need to remap the results, and it's probably a better idea to
> build that string in java code anyway.
> 
> Larry
> 
> 
> On 10/18/07, ramy <ra...@gmail.com> wrote:
>>
>> I have a list over which the select statement has to be run
>> my sql is like
>>
>> <select id="selectAssgnResults"  parameterClass="java.util.List"
>>
>>     resultMap="RschResult" >
>>     select
>>     <iterate  property="reportData" open=" " close=" " conjunction=",">
>>       $[]$
>>
>>      </iterate>
>>
>>        from RSCH
>>
>>   </select>
>>
>>
>> It throws me an error
>>
>> --- Check the selectAssgnResults.
>> --- Check the parameter map.
>> --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
>> list from JavaBean. Cause java.lang.StringIndexOutOfBoundsException:
>> String
>> index out of range: -1
>>
>> --
>> View this message in context:
>> http://www.nabble.com/passing-a-list-to-sqlmap-tf4648784.html#a13280522
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/passing-a-list-to-sqlmap-tf4648784.html#a13281873
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: passing a list to sqlmap

Posted by Larry Meadors <lm...@apache.org>.
you need to remap the results, and it's probably a better idea to
build that string in java code anyway.

Larry


On 10/18/07, ramy <ra...@gmail.com> wrote:
>
> I have a list over which the select statement has to be run
> my sql is like
>
> <select id="selectAssgnResults"  parameterClass="java.util.List"
>
>     resultMap="RschResult" >
>     select
>     <iterate  property="reportData" open=" " close=" " conjunction=",">
>       $[]$
>
>      </iterate>
>
>        from RSCH
>
>   </select>
>
>
> It throws me an error
>
> --- Check the selectAssgnResults.
> --- Check the parameter map.
> --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
> list from JavaBean. Cause java.lang.StringIndexOutOfBoundsException: String
> index out of range: -1
>
> --
> View this message in context: http://www.nabble.com/passing-a-list-to-sqlmap-tf4648784.html#a13280522
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: passing a list to sqlmap

Posted by dereje abay <de...@gmail.com>.
Hi Ramy,
See the two options below

 Option1 : remove property attribute from the iterator tag
<select id="selectAssgnResults"  parameterClass="java.util.List"

   resultMap="RschResult" >
   select
   <iterate   open=" " close=" " conjunction=",">
     $[]$

    </iterate>

      from RSCH


Option 2.  Pass  an object that contains "reportData"  as  its member
variable. Make sure you pass same data type.
Dereje
On 10/18/07, ramy <ra...@gmail.com> wrote:
>
>
> I have a list over which the select statement has to be run
> my sql is like
>
> <select id="selectAssgnResults"  parameterClass="java.util.List"
>
>    resultMap="RschResult" >
>    select
>    <iterate  property="reportData" open=" " close=" " conjunction=",">
>      $[]$
>
>     </iterate>
>
>       from RSCH
>
> </select>
>
>
> It throws me an error
>
> --- Check the selectAssgnResults.
> --- Check the parameter map.
> --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
> list from JavaBean. Cause java.lang.StringIndexOutOfBoundsException:
> String
> index out of range: -1
>
> --
> View this message in context:
> http://www.nabble.com/passing-a-list-to-sqlmap-tf4648784.html#a13280522
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>