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

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

运行环境

SpringBoot

表现结果

1、有的SQL能够执行,有的SQL不行,运行也不报错,但就是执行后没有效果。
2、但SQL单独再oracle中是执行成功的。

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);   

异常排查

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

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

瞥一眼,还真看不出来是哪块问题,我是通过RESTClient工具调试接口。
Mybatis异常-SQL执行没反应,但oracle单独执行正常_第1张图片

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

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

删除后为:

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

所以,大伙如果再碰到类似情况,就检查下自己的请求参数是不是有问题。

错误总结

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

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);   

你可能感兴趣的:(oracle,sql,mybatis,异常)