ibatis mybatis传入List参数

--ibatis
<select id="getWzlb"  parameterClass="map" resultClass="java.util.HashMap">
        select ... from wz09
        where 1=1
    <isNotEmpty prepend="AND" property="ids"> <!-- ids是map的一个key -->
        id in
            <iterate property="ids" open="(" conjunction="," close=")">
                #ids[]#
            </iterate>
    </isNotEmpty>
</select>  

--mybatis
select id, city_id, owner_id
  from item
 where id in
<foreach item="item" index="index" collection="list"  open="(" separator="," close=")">
     #{item}
</foreach>
select r.id, r.info_id, r.item_id,
  from rent_content r
 where r.id NOT IN (SELECT rent_content_id FROM rent_calendar WHERE rent_content_id = r.id AND begin_time <#{endDate}  AND end_time > #{startDate})
   and r.car_item_id in
  <foreach item="item" index="index" collection="list"  open="(" separator="," close=")">
       #{item}
  </foreach> 
时间: 2024-08-27 14:45:00

ibatis mybatis传入List参数的相关文章

mybatis传入map参数parameterType

基本数据类型:包含int,String,Date等.基本数据类型作为传参,只能传入一个.通过#{参数名} 即可获取传入的值 复杂数据类型:包含JAVA实体类.Map.通过#{属性名}或#{map的KeyName}即可获取传入的值 2.记住,是通过map的key get到的value作为传入.而不是key传入 复杂数据类型:包含JAVA实体类.Map.通过#{属性名}或#{map的KeyName}即可获取传入的值

mybatis传入map参数,map中包含list(输入参数)

1.xml中配置: <!-- 根据条件查询满足条件的ID集合开始 --> <select id="getQuestionsIdsForExamPaper" resultType="java.lang.String" parameterType="hashmap"> select questionId from questions <where> <include refid="query_que

MyBatis传入参数为集合、数组SQL写法

参考:http://blog.csdn.net/small____fish/article/details/8029030 foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach标签的属性主要有item,index,collection,open,separator,close. item 表示集合中每一个元素进行迭代时的别名,随便起的变量名: index 指定一个名字,用于表示在迭代过程中,每次迭代到的位置,不常用: open 表示该语句以什么开始,常用"

MyBatis传入多个参数的问题

一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList" parameterType="java.lang.String" resultType="XXBean"> select t.* from tableName t where t.id= #{id} </select> 其中方法名和ID一致,

小峰mybatis(2)mybatis传入多个参数等..

一.mybatis传入多个参数: 前面讲传入多个参数都是使用map,hashmap:key value的形式:-- 项目中开发都建议使用map传参: 比如现在通过两个参数,name和age来查询: 通过两个参数来查的,了解下就行了: 数据库中存在t_student记录: 1)测试代码StudentTest.java: @Test public void testSearchStudents() { logger.info("根据name和age查询学生"); List<Stude

mybatis mapper文件sql语句传入hashmap参数

1.怎样在mybatis mapper文件sql语句传入hashmap参数? 答:直接这样写map就可以 <select id="selectTeacher" parameterType="Map" resultType="com.myapp.domain.Teacher"> select * from Teacher where c_id=#{id} and sex=#{sex} </select>

Mybatis传入参数为map

Mapper: List<AdPayConfigEntity> selectByAdType(@Param("status") Integer... status); XML:<select id="selectByAdType" parameterType="map" resultMap="BaseResultMap"> SELECT * from sky_ad_pay_config WHERE ad

MyBatis传入参数为集合 list 数组 map写法

foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach元素的属性主要有item,index,collection,open,separator,close.item表示集合中每一个元素进行迭代时的别名,index指定一个名字,用于表示在迭代过程中,每次迭代到的位置,open表示该语句以什么开始,separator表示在每次进行迭代之间以什么符号作为分隔符,close表示以什么结束,在使用foreach的时候最关键的也是最容易出错的就是collection属性

ibatis输入多个参数

ibatis输入多个参数 在ibatis中,会发现其输入参数只能有一个,于是当出现需要进行多个输入参数的时候,就要想点办法了,我看到的有以下两种比较好的方法能够解决这个问题1) 用String代替<select id="checkLogin" parameterClass="java.lang.String" resultClass="java.lang.Integer">SELECT count(*) AS value FROM u