Mybatis学习第6节 -- 修改功能和修改部分字段

方案一, 先查询再修改

接口
int updateShop(Shop shop);
映射
<update id="updateShop" parameterType="Shop">
UPDATE
`tb_shop`
SET

`owner_id` = 'owner_id',
`area_id` = 'area_id',
`shop_category_id` = 'shop_category_id',
`shop_name` = 'shop_name',
`shop_desc` = 'shop_desc',
`shop_addr` = 'shop_addr',
`phone` = 'phone',
`shop_img` = 'shop_img',
`priority` = 'priority',
`create_time` = 'create_time',
`last_edit_time` = 'last_edit_time',
`enable_status` = 'enable_status',
`advice` = 'advice'
WHERE `shop_id` = #{id} ;
</update>
测试略

方案二,动态SQL

 
 
 
 
posted @ 2019-03-16 19:03  不怕旅途多坎坷  阅读(1197)  评论(0编辑  收藏  举报