//万能的Map int addUser2(Mapmap);
insert into mybatis.user (id, name,pwd) values (#{id},#{name},#{pwd});
@Test public void addUser2(){ SqlSession sqlSession = MybatisUtils.getSqlSession(); UserMapper mapper = sqlSession.getMapper(UserMapper.class); MapJava代码执行的时候,传递通配符 % %map = new HashMap (); map.put("id",5); map.put("name","王五"); map.put("pwd","2222333"); mapper.addUser2(map); sqlSession.commit(); sqlSession.close(); }
在sql拼接中使用通配符List
userList = mapper.getUserLike("%李%");
select * from mybatis.user where name like "%"#{value}"%"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)