0

I'm trying to get return value from DB but it return [] instead of data

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>

in Oracle DB SQL select is working fine without a single problem. but it keep return this []

anyone know the problem??

Adrian Shum
  • 38,812
  • 10
  • 83
  • 131
  • 1
    Assuming "it return '[]'" means that `lists` is empty, the query returns an empty result. If you are using Spring Boot, add `logging.level.com.pkg.YourMapper=TRACE` to your `application.properties` to log the parameters and the result (replace "com.pkg.YourMapper" with the fully-qualified name of your mapper). – ave Oct 23 '19 at 07:03
  • what do you mean by `[]` ? An array (which couldn't even compile)? An empty list? or something else? – Adrian Shum Oct 24 '19 at 07:59

1 Answers1

0

You are using the selectList api and the XML declaration the return type is map, but you did not specify how the query results must fill the map. If you want that every row from the db is mapped to a Map<String, Object> you must write a ResultHandler.

You can use the selectMap api but the result is a Map<String,AnObject> where AnObject is a class that represents the columns selected in the query.

You can check this respone for more details.

Giovanni
  • 3,951
  • 2
  • 24
  • 30