@Testpublic void testForeach() { DynamicSqlEngine engine = new DynamicSqlEngine(); String sql = ("select * from user where name in <foreach collection='list' open='(' separator=',' close=')'>#{item.name}</foreach>"); Map<String, Object> map = new HashMap<>(); ArrayList<User> arrayList = new ArrayList<>(); arrayList.add(new User(10, "tom")); arrayList.add(new User(11, "jerry")); map.put("list", arrayList); SqlMeta sqlMeta = engine.parse(sql, map); System.out.println(sqlMeta.getSql()); sqlMeta.getJdbcParamValues().forEach(System.out::println);}
请发表评论