• 动态set mybatis与ibatis的写法


    mybatis:

    <set>
                <if test="obj.buyerId != null">
                    buyerId = #{obj.buyerId},
                </if>
                <if test="obj.country != null and obj.country.length() > 0">
                    country = #{obj.country},
                </if>
                <if test="obj.province != null and obj.province.length() > 0">
                    province = #{province},
                </if>
                <if test="obj.city != null and obj.city.length() > 0">
                    city = #{obj.city},
                </if>
                <if test="obj.district != null and obj.district.length() > 0">
                    district = #{obj.district},
                </if>
                <if test="obj.detailAddress != null and obj.detailAddress.length() > 0">
                    detail_address = #{obj.detailAddress},
                </if>
                <if test="obj.country != null and obj.country.length() > 0">
                    country = #{obj.country},
                </if>
                <if test="obj.isDefault != null and obj.isDefault.length() > 0">
                    isDefault = #{obj.isDefault}
                </if>
            </set>

    ibatis:

    <dynamic prepend="SET">
                <isNotEmpty prepend="," property="obj.name">
                    name = #obj.name#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.nick">
                    nick = #obj.nick#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.lastLoginDate">
                    last_login_date = #obj.lastLoginDate#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.weixinUnionId">
                    weixin_union_id = #obj.weixinUnionId#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.email">
                    email = #obj.email#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.qq">
                    qq = #obj.qq#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.weixinOpenId">
                    weixin_open_id = #obj.weixinOpenId#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.weixinId">
                    weixin_id = #obj.weixinId#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.sessionKey">
                    session_key = #obj.sessionKey#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.mobile">
                    mobile = #obj.mobile#
                </isNotEmpty>
                <isNotNull prepend="," property="obj.sex">
                    sex = #obj.sex#
                </isNotNull>
                <isNotEmpty prepend="," property="obj.avatar">
                    avatar = #obj.avatar#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.sellerId">
                    seller_id = #obj.sellerId#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.shopId">
                    shop_id = #obj.shopId#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.mpId">
                    mp_id = #obj.mpId#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.city">
                    city = #obj.city#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.province">
                    province = #obj.province#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.language">
                    language = #obj.language#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.country">
                    country = #obj.country#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.phoneNumber">
                    phone_number = #obj.phoneNumber#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.countryCode">
                    country_code = #obj.countryCode#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.memberType">
                    member_type = #obj.memberType#
                </isNotEmpty>
                <isNotEmpty prepend="," property="obj.remark">
                    remark = #obj.remark#
                </isNotEmpty>
            </dynamic>
  • 相关阅读:
    Solr&SpringDataSolr
    Redis简单介绍与使用
    ueditor文本编辑器
    FastDFS
    Vue.js快速入门
    分布式架构Duboo+Zookeeper的基础使用
    Linux基本操作&&Linux操作MySQL
    23种设计模式之代理模式(动态代理)
    23种设计模式之代理模式(静态代理)
    MongoDB入门培训 | 8周入门NoSQL No.1数据库
  • 原文地址:https://www.cnblogs.com/kingsonfu/p/9273060.html
Copyright © 2020-2023  润新知