pasysxa / mybatisnet

Automatically exported from code.google.com/p/mybatisnet
0 stars 0 forks source link

Issue with select with iteration - "off by one" problem? #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I am using mybatis.net 1.6.2.0 (data mapper) with data access 1.9.2.0

I have "iterated" select like this:

<select id="GetIdsByPolicyIdAndCodes" resultClass="int" 
parameterClass="System.Collections.IDictionary">
                SELECT IDPredmetOsig
                FROM PredmetOsig
                WHERE (IDPolisa = #InsurancePolicyId#) AND SifPredmetOsig IN 
                <iterate open="(" close=")" conjunction=",">
                        #InsuredSubjectCodes[]#
                </iterate>
        </select>

#InsuredSubjectCodes# is key of entry in dictionary where value is list of 
strings. It works correctly if list of strings is of size 2 or greater. 

However if I pass list with just one element I got:

IBatisNet.DataAccess.Exceptions.DataAccessException : DaoProxy : unable to 
intercept method name 'GetIdsByPolicyIdAndCodes', cause : Index was out of 
range. Must be non-negative and less than the size of the collection.
Parameter name: index
  ----> System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Please provide any additional information below.

Ok, there is not much point in select...where...in with only one element but 
this is general purpose statement which should work regardless of size of input 
collection.

Original issue reported on code.google.com by rss...@gmail.com on 15 Aug 2011 at 6:31