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>

你可能感兴趣的:(mybatis)