Mybatis中生成动态SQL的标签有四类,分别是: if choose (when, otherwise) trim (where, set) foreach 1.if 当需要动态生成where条件时,可以使用if标签: <select id="findActiveBlogWithTitleLike" resultType="Blog"> SELECT * FROM BLOG WHERE state = ‘ACTIVE’ <if test=&qu…
有时候开发中需要根据多个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…
1.常见错误: There is no getter for property named 'parentId' in 'class java.lang.Long'(或者String) org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'paren…