Mybatis - 没有任何错误它只是 return [] 而不是数据库数据

Mybatis - without any error it just return [] instead of db data

我正在尝试从数据库中获取 return 值,但它 return [] 而不是数据

JAVA Restful

    @RequestMapping("/regLocal")
    public List<Map<String, Object>> regist_local(@RequestBody Map<String, Object> params){
    Map<String, String> map = new HashMap<String, String>();

    String location = (String) params.get("location_name"); // 'country'
    String code = (String) params.get("location_code"); // '1'

    map.put("location", location);
    map.put("code", code);
    List<Map<String, Object>> lists = se.selectList(ns+".regLocal", map); // it return []

    return lists;
}

Mybatis

<select id="regLocal" resultType="map">
    select hll.hll_code hll_code, hll.hll_name hll_name 
    from hl_local hll, h_location hl
    where hll.hl_location = #{code} and hl.hl_name = #{location}
</select>

在 Oracle DB SQL select 中工作正常,没有任何问题。 但它保持 return 这个 []

有人知道这个问题吗??

您正在使用 selectList api 和 XML 声明 return 类型是地图,但您没有指定查询结果必须如何填充地图.如果您希望数据库中的每一行都映射到 Map<String, Object>,您必须编写一个 ResultHandler。

您可以使用 selectMap api,但结果是 Map<String,AnObject>,其中 AnObject 是 class,表示在查询中选择的列。

您可以查看this respone了解更多详情。