1

我在我的项目中,在我的一个 serviceImpl 中使用 mybatis-spring,springMVC

public int setRetransmissionState(Map params) {
    String ids = (String) params.get("ids");
    List<String> list = Arrays.asList(ids.split(","));
    int result = 0;
    for (String id : list) {
        String retransmissionId = CreateOrderIDUtil.getUniqueKey("rt");
        params.put("sequenceId", id);
        params.put("retransmissionId", retransmissionId);
        int i = this.dao.setRetransmissionState(params);
        int j = this.dao.insertRetransmission(params);
        result++;
    }
    return result;
} 

道实现

@Autowired
private SqlSession sqlSession;

@Override
public int setRetransmissionState(Map params) {
    return this.sqlSession.update("retransmission.setRetransmissionState", params);
}

@Override
public int insertRetransmission(Map params) {
    return this.sqlSession.insert("retransmission.insertRetransimssion", params);
}

映射器.xml

<update id="setRetransmissionState" parameterType="java.util.HashMap">
    UPDATE
        CS_APP_RELATION
    SET
        IS_RETRANSMISSION = '1',
        IS_RETRANSMITTING = '1',
        RETRANSMISSION_ID = #{retransmissionId}
    WHERE 
        SEQUENCE_ID = #{sequenceId}
</update>

<insert id="insertRetransimssion" parameterType="java.util.HashMap">
    INSERT
    INTO
        CS_MODEL_RETRANSMISSION
        (
            RETRANSMISSION_ID,
            RETRANSMISSION_SOURCE,
            RETRANSMISSION_TARGET,
            OPERATOR_ID,
            RETRANSMISSION_TIME,
            RETRANSMISSION_SEQ,
            RETRANSMISSION_POSTSCRIPT,
            RETRANSMISSION_STATE,
            RETRANSMISSION_TYPE
        )
    VALUES
        (
            #{retransmissionId},
            '',
            #{targetId},
            #{operatorID},
            TO_CHAR(sysdate,'yyyy-mm-dd hh24:mi:ss'),
            '',
            '',
            '0',
            '1'
        )
</insert>

让我感到困惑的是,无论 List 的长度是多少,所有的插入都会成功,但更新效果只有一次,JVM 不会抛出任何异常,它告诉我一切顺利,这是什么问题?

4

0 回答 0