mybatis 当需要批量插入并更新主键相同的数据时的处理方法

该方法 如果表中没有没有主键对应的数据就添加一条 如果有的话就更新该条数据


    REPLACE into representatives_and_principal_personnel
    (id,examine_and_approve_id, idcard_number, name, sex, duty, rankv, birth,
    standard_culture, workspace, state, phone, have_bad_record, amount_of_contribution)
    values
    
        (#{representativesAndPrincipalPersonnel.id},
        #{representativesAndPrincipalPersonnel.examine_and_approve_id},
        #{representativesAndPrincipalPersonnel.idcard_number},
        #{representativesAndPrincipalPersonnel.name},
        #{representativesAndPrincipalPersonnel.sex},
        #{representativesAndPrincipalPersonnel.duty},
        #{representativesAndPrincipalPersonnel.rankv},
        #{representativesAndPrincipalPersonnel.birth},
        #{representativesAndPrincipalPersonnel.standard_culture},
        #{representativesAndPrincipalPersonnel.workspace},
        #{representativesAndPrincipalPersonnel.state},
        #{representativesAndPrincipalPersonnel.phone},
        #{representativesAndPrincipalPersonnel.have_bad_record},
        #{representativesAndPrincipalPersonnel.amount_of_contribution})
    

你可能感兴趣的:(mybatis 当需要批量插入并更新主键相同的数据时的处理方法)