mybatis动态查询备忘

   

public List<String> selectByIds(Set<String> ids, String tableName) {
        if (ids == null || ids.size() <= 0 || StringUtils.isEmpty(tableName)) {
            return null;
        }
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("tableName", tableName);
        map.put("ids", ids);
        return selectListWithMethodName(map);
    }

<select id ="selectByIds"  resultType="java.lang.String" parameterType="java.util.Map" >
         select   id from ${tableName}
            where id in
              <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
                        #{item}
                </foreach>
</select>

猜你喜欢

转载自lhg4study.iteye.com/blog/1879298