ITeye博客

mybatis动态查询备忘

lhg4study · 2013-05-29 11:39 · 开源软件 · Markdown

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>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。