Mybatis异常-SQL执行没反应,但oracle单独执行正常

转载请注明来源:http://blog.csdn.net/loongshawn/article/details/50512475java

运行环境

SpringBootweb

表现结果

一、有的SQL可以执行,有的SQL不行,运行也不报错,但就是执行后没有效果。
二、但SQL单独再oracle中是执行成功的。sql

SQL片断

<select id="checkDaohangProcessedStatusByRefid" parameterType="Map" resultType="java.lang.Integer">
        SELECT count(*)
        FROM TBS_ROAD t
        WHERE t.id = #{id} AND t.status = '04' AND t.clienttype = #{organization}
    </select>

    <select id="checkPoiProcessedStatusByRefid" parameterType="Map" resultType="java.lang.Integer">
        SELECT count(*)
        FROM T_TABLE_BAOCUO t
        WHERE t.id = #{id} AND t.status = '03' AND t.clienttype = #{organization}
    </select>

    <update id="closeDaohangInfoByRefid" parameterType="Map">
        UPDATE TBS_ROAD t
        SET t.status = '05'
        WHERE t.id = #{id} AND t.clienttype = #{organization}
    </update>

    <update id="closePoiInfoByRefid" parameterType="Map">
        UPDATE T_TABLE_BAOCUO t
        SET t.status = '01'    
        WHERE t.id = #{id} AND t.clienttype = #{organization}
    </update>

Java Mapper接口

// 2016-01-07 add
    public OnStarPoi selectPoiInfoByRefid(String id);

    public OnStarDao selectDaohangInfoByRefid(String id);

    public Integer updatePoiReceiveInfoByRefid(HashMap<String,String> map);

    public Integer updateDaohangReceiveInfoByRefid(HashMap<String,String> map);

    // 2016-01-12 add
    public List<OnStarPoi> selectPoiInfoAll(String organization);

    public List<OnStarDao> selectDaohangInfoAll(String organization);

    // 2016-01-13 add
    // public Integer checkPoiProcessedStatusByRefid(String id);

    public Integer checkDaohangProcessedStatusByRefid(HashMap<String,String> map);

    // public Integer checkPoiCloseStatusByRefid(String id);

    public Integer checkDaohangCloseStatusByRefid(HashMap<String,String> map);

    // public Integer openPoiInfoByRefid(String id);

    public Integer openDaohangInfoByRefid(HashMap<String,String> map);

    // public Integer closePoiInfoByRefid(String id);

    public Integer closeDaohangInfoByRefid(HashMap<String,String> map);

Java执行片断

Integer count = 0;

// 封装
HashMap<String,String> map = new HashMap<String,String>();
map.put("id", issue_id);
map.put("organization", organization+"");

count = issueMapper.updatePoiReceiveInfoByRefid(map);

异常排查

查看当时请求的接口参数:oracle

{"key":"12344445556666",
"user":"fffff",
"method":"gaokuaiOnstarFeedbackSelectAll",
"operation_type":"03",
"organization":10,
"type":"02",
"data":[ {"gaokuai_id":" 600001357"}
       ]
}

瞥一眼,还真看不出来是哪块问题,我是经过RESTClient工具调试接口。
这里写图片描述app

倒腾了1小时,觉得配置出错了。后来才发现是” 600001357”前面多了个空格,删除掉就OK了。svg

"data":[ {"gaokuai_id":" 600001357"}

删除后为:函数

"data":[ {"gaokuai_id":"600001357"}

因此,大伙若是再碰到相似状况,就检查下本身的请求参数是否是有问题。工具

错误总结

后续对待接口中的参数,要进行预处理,好比去掉先后的空格符号,使用java的trim()函数。spa

Integer count = 0;

// 封装
HashMap<String,String> map = new HashMap<String,String>();
map.put("id", issue_id.trim());
map.put("organization", organization+"");

count = issueMapper.updatePoiReceiveInfoByRefid(map);