mybatis实现有则更新无则插入

<insert id="insertUser"  useGeneratedKeys="true" keyProperty="id" keyColumn="id"
            parameterType="com.foreigners.entity.User">
        insert INTO
        t_user(openId, name, gender, phoneNumber)
        VALUES
        (#{openId},#{name},#{gender},#{phoneNumber})
        ON DUPLICATE KEY UPDATE
        name = #{name},
        gender = #{gender},
        phoneNumber = #{phoneNumber}
</insert>

 

posted @ 2019-03-29 16:48  🍒lychee.wang  阅读(1086)  评论(0编辑  收藏  举报