mybatis动态传入表名,字段名,查询条件进行查询

mybatis动态传入表名,字段名,查询条件进行查询

菜鸟一枚,不足之处请多多指出

BaseMapper.xml

// BaseMapper.xml
<select id="findByFiled" resultType="java.util.Map" statementType="STATEMENT" >
       select ${fields} from ${tableName} where ${exa}
  </select>

BaseMapper.java

// BaseMapper.xml
    List<Map<String,Object>> findByFiled(@Param("fields") String fields, @Param("tableName") String tableName, @Param("exa") String exa);

TestService.java

// BaseMapper.xml
    public List<Map<String, Object>> test() {
		return userMapper.findByFiled("*", "trd_user", " id=1 ");
	}

你可能感兴趣的:(mybatis)