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>
相關文章
相關標籤/搜索