对于mybatis的参数类型是集合数组的时候进行查询. 第一种:参数list使用mybatis的标签 SELECT * FROM TABLE_NAME AS a <where> <if test="constomerGradeArray!=null and constomerGradeArray.length!=0"> AND a.constomer_grade in <foreach collection="constomerGradeArra
有时候开发中需要根据多个ID去查询,可以将ID封装为List或者数组然后使用MyBatis中的foreach标签构建in条件. 这里我将ID封装为String[]作为参数. <select id="selectList" parameterType="java.util.List" resultType="java.lang.Integer"> SELECT COUNT(1) FROM t_user WHERE id IN <f
参考:http://blog.csdn.net/small____fish/article/details/8029030 foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach标签的属性主要有item,index,collection,open,separator,close. item 表示集合中每一个元素进行迭代时的别名,随便起的变量名: index 指定一个名字,用于表示在迭代过程中,每次迭代到的位置,不常用: open 表示该语句以什么开始,常用"
mybatis 比 ibatis 改进了很多,特别是支持了注解,支持了plugin inteceptor,也给开发者带来了更多的灵活性,相比其他ORM,我还是挺喜欢mybatis的. 闲言碎语不要讲,今天研究了下mybatis的typeHandler: 先看这样一张表(postgresql) create table user ( id serial not null name ), age integer, emails character varchar[], -- varchar 数组 表