没太明白同学要表达的意思,请详细描述一下,你getShopId是在什么情况下调用的呢?
<insert id="insertShop" useGeneratedKeys="true" keyColumn="shop_id"
keyProperty="shopId">
INSERT INTO
tb_shop(owner_id, area_id, shop_category_id,
shop_name, shop_desc, shop_addr,
phone, shop_img, priority,
create_time, last_edit_time, enable_status,
advice)
VALUES
(#{owner.userId},#{area.areaId},#{shopCategory.shopCategoryId},#{shopName},
#{shopDesc},#{shopAddr},#{phone},#{shopImg},#{priority},
#{createTime},#{lastEditTime}, #{enableStatus},#{advice})
</insert>
在我们的mapper里,useGeneratedKeys="true" 也就是说你传入的shop实体类对象一开始是没有shopId的,当插入成功后,会自动往你属性里面的shop插入shopId,没太明白为什么会使用getshpId