大博主 2017-10-16 06:56 采纳率: 38.9%
浏览 1179
已采纳

java前台修改状态,有显示,但是不能同步更新到数据库,我写的单元测试又可以,前台调的接口更新不了

@Override
public int updateGoodsIsStops(UpdateGoodsIsStopsReq request, Holder holder) {
NDC.push(request.session.sessionKey);
LOG.begin();
int errorCode = 0;
UpdateGoodsIsStopsResp response = new UpdateGoodsIsStopsResp();
try {
LOG.debug("request: {0}", request);
if (Objects.isNull(request.session) || Objects.isNull(request.session.sessionKey)
|| request.session.sessionKey.isEmpty()) {
throw new ErrorCodeException(ErrorCode.ERR_ARCHIVES_PARAM, "session is empty.");
}

        response.errorCode = goodsService.updateGoodsIsStops(request.ids, request.isStop);
    } catch (ErrorCodeException e) {
        LOG.error(e);
        errorCode = e.getErrorCode().value();
    } catch (Exception e) {
        LOG.error(e);
        errorCode = ErrorCode.ERR_ARCHIVES_RUNTIME.value();
    } finally {
        // If you never call it, then your application is sure to run out of memory.
        NDC.remove();
    }
    holder.setValue(response);
    LOG.debug("ret: {0}, response: {1}", errorCode, response);
    return errorCode;
}

    这是相当于controller层的代码

     <update id="updateGoodsIsStops" parameterType="java.util.List">
    update dt_ec.goods set is_stop =#{isStop} where goods_id in
    <foreach collection="ids" item="item" index="index"
        open="(" separator="," close=")">
        #{item}
    </foreach>
</update>
  • 写回答

3条回答 默认 最新

  • longlong3207 2017-10-16 09:01
    关注

    单元测试以后数据库中有没有改变?,
    你是用的ajax访问这个方法吗?
    用火狐访问你的项目,f12 点击网络点击你访问的路径,点击参数,截图一下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • 郭老师的小迷弟雅思莫了 Java领域新星创作者 2017-10-16 07:08
    关注

    有没有报错信息?还有就是你打个断点调试下,应该很快就能找出错误。

    评论
  • 安小菜 2017-10-16 07:58
    关注


    update dt_ec.goods set is_stop =#{isStop} where goods_id in
    open="(" separator="," close=")">
    #{item}

    看你的sql。parameterType是list。这个list是ids还是isStop+ids?如果是前者,那isStop呢?如果是后者,好像parametrType不可以这样写把?

    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 大一Python字典
  • ¥15 multisim电路设计(相关搜索:设计报告)
  • ¥15 从github上下载的项目到ecplise上咋运行
  • ¥15 PC-lint Plus
  • ¥15 gpl24676注释
  • ¥15 php5.3内存泄露
  • ¥15 DigSilent如何复制复合模型到自己案例?
  • ¥15 求日版华为b610s-77a 官方公版固件,有偿
  • ¥15 关于#java#的问题,请各位专家解答!(相关搜索:java程序)
  • ¥15 linux tsi721的驱动编译后 insmod 提示 报错