有时候开发中需要根据多个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
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
当 where 中的条件使用的 if 标签较多时,这样的组合可能会导致错误.当 java 代码按如下方法调用时: @Test public void select_test_where() { User user = new User(); user.setUsername(null); user.setSex(1); List<User> userList = this.dynamicSqlMapper.getUsertList_where(user); for (User u : user