关于ibatis如何传入数组作为参数

转载:感谢 涂剑凯
http://blog.sina.com.cn/bdstjk

 

一:传入参数仅有数组

       

java代码:

            string[] strValue = new string[] { "1", "2", "3" };

            Reader.QueryForList("WebApp_Ibatisnet.dao.GetEmailList_Test", strValue );

二:传入参数有数组,且有其他数据
        

java代码:

            TestIn ti = new TestIn();
            ti.Count = 1;
            ti.ArrValue = strValue;
            return Reader.QueryForList("WebApp_Ibatisnet.dao.GetEmailList_Test3", ti);

实体类:

   public class TestIn
    {
        private int count;

        public int Count
        {
            get { return count; }
            set { count = value; }
        }

        private string[] arrValue;

        public string[] ArrValue
        {
            get { return arrValue; }
            set { arrValue = value; }
        }
    }

三:in后面的数据确定,使用string传入

 

        

java代码:

                Reader.QueryForList("WebApp_Ibatisnet.dao.GetEmailList_Test2", "1,2,3");

 

 

其他信息:

Iterate的属性:
prepend
 可被覆盖的SQL成部分,添加在句的前面(可
property
 java.util.List的用于遍的元素(必
open
 整个遍内容体始的字符串,用于定括号(可
close
 -整个遍内容体束的字符串,用于定括号(可
conjunction
 次遍内容之的字符串,用于定ANDOR(可
历类java.util.List的元素。

你可能感兴趣的:(Mybatis(ibatis))