分页关联查询时 出现查出数据和条数不匹配 级联查询

商品表   图片表

<resultMap id="BaseResultMap" type="com.shop.domain.admin.ShopItem" >
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="item_coding" property="itemCoding" jdbcType="VARCHAR" />
<result column="item_name" property="itemName" jdbcType="VARCHAR" />
<result column="item_name_second" property="itemNameSecond" jdbcType="VARCHAR" />
<result column="item_type" property="itemType" jdbcType="VARCHAR" />
<result column="warehouse" property="warehouse" jdbcType="VARCHAR" />
<result column="price" property="price" jdbcType="DOUBLE" />
<result column="brand" property="brand" jdbcType="VARCHAR" />
<result column="item_status" property="itemStatus" jdbcType="VARCHAR" />
<result column="delivery_info" property="deliveryInfo" jdbcType="VARCHAR" />
<result column="sales_service" property="salesService" jdbcType="VARCHAR" />
<result column="product_note" property="productNote" jdbcType="VARCHAR" />
<result column="item_cat_id" property="itemCatId" jdbcType="INTEGER" />
<result column="item_cat_name" property="itemCatName" jdbcType="VARCHAR" />
<result column="barcode" property="barcode" jdbcType="VARCHAR" />
<result column="item_state" property="itemState" jdbcType="VARCHAR" />
<result column="creat_time" property="creatTime" jdbcType="VARCHAR" />
<result column="update_time" property="updateTime" jdbcType="VARCHAR" />
</resultMap>

 

 

<resultMap id="BaseResultMap"
type="com.shop.domain.admin.ShopImage">
<result column="id" property="id" jdbcType="VARCHAR" />
<result column="pid" property="pid" jdbcType="INTEGER" />
<result column="pid_second" property="pidSecond"
jdbcType="VARCHAR" />
<result column="image_address" property="imageAddress"
jdbcType="VARCHAR" />
<result column="creat_time" property="creatTime"
jdbcType="VARCHAR" />
</resultMap>

 

 

<sql id="base_sql" >
id, item_coding, item_name, item_name_second, item_type, price, warehouse, brand,
item_status, delivery_info, sales_service, product_note, item_cat_id, item_cat_name,
barcode, item_state, creat_time, update_time ,id as sss
</sql>

<!-- 级联查询 -->
<resultMap id="BaseResultMapCascade" type="com.shop.domain.admin.ShopItem" extends="BaseResultMap">
<collection property="imageInfo" javaType="java.util.List" ofType="com.shop.domain.admin.ShopImage" select="com.shop.dao.admin.ShopImageMapper.selectImageBypiidSecond" column="{pidSecond=sss}">
</collection>
</resultMap>

 

 

<!-- 查询商品详情图片 -->
<select id="selectImageBypiidSecond" parameterType="map"
resultMap="BaseResultMap">
select
<include refid="base_sql"></include>
from shop_image
where pid_second = #{pidSecond}
</select>

 

<!-- 分页查询商品信息 -->
<select id="selectCommodityInfo" parameterType="map" resultMap="BaseResultMapCascade">
select <include refid="base_sql"></include> from 
shop_item
where 1=1 
<if test="wheres != null">
${wheres}
</if>
GROUP BY id
order by creat_time
<if test="page !=null and number != null and number !=''">
limit #{page},#{number}
</if>
</select>

 

posted @ 2019-10-12 11:42  雨后丶云初霁  阅读(343)  评论(0编辑  收藏  举报