首页 > 其他 > 详细

Mybatis 采坑记录--set标签的使用

时间:2017-12-17 11:42:23      阅读:239      评论:0      收藏:0      [点我收藏+]

 

 <!--根据poi_info表的id和city_id更新flag_hinterland_flows的poi_id和city_id-->
    <select id="selectPoiAndCityId" parameterType="java.lang.Long" resultType="com.wormpex.gs.stat.service.dao.entity.baseinfo.PoiAndCityId">
        select n.id as poiId,n.city_id as cityId,n.code as code from poi_info n inner join flag_hinterland_flows m   
/*1用inner join,只返回满足匹配条件的数据,减少数据库io次数*/
on m.flag_code=n.code <where> <if test="id != null"> n.id<![CDATA[<=]]>#{id,jdbcType=BIGINT} </if> </where> </select> <update id="updatePoiAndCityId" parameterType="com.wormpex.gs.stat.service.dao.entity.baseinfo.PoiAndCityId" > update flag_hinterland_flows <set> poi_id=#{poiId,jdbcType=BIGINT}, <if test="cityId != null"> city_id=#{cityId,jdbcType=BIGINT}, </if> </set> /*2set标签可以自动忽略if标签中多余的逗号,但是,对于if标签里面再嵌套一层if的时候,set标签就不能自动忽略了*/ where /*3where放到set标签外边*/ flag_code=#{code,jdbcType=VARCHAR} </update>

 

Mybatis 采坑记录--set标签的使用

原文:http://www.cnblogs.com/Allen-win/p/8051561.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!