为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

catspeake 2023-12-10 09:42:32
我试图从数据库获取返回值,但它返回[]而不是数据JAVA 宁静    @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;}我的鞋<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 中工作正常,没有任何问题。但它一直返回这个[]有人知道问题吗?
查看完整描述

1 回答

?
子衿沉夜

TA贡献1828条经验 获得超3个赞

您正在使用selectListapi并且XML声明返回类型是map,但是您没有指定查询结果必须如何填充map。如果您希望数据库中的每一行都映射到 a,Map<String, Object>则必须编写一个 ResultHandler。

您可以使用selectMapapi,但结果是一个Map<String,AnObject>,其中 AnObject 是表示查询中选择的列的类。

查看完整回答
反对 回复 2023-12-10
  • 1 回答
  • 0 关注
  • 49 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信