mybaits stepped on the pit: the returned entity class is a list

We found that when the xml file sets the return value type to entity class, the default query result is a list. At this time, the interface in mapper should be accepted by list. If a single object is used to accept, an error will be reported:

List<GoodsVo> findGoodsVo(); 
GoodsVo findGoodsVoByGoodsId(Long GoodsId);//报错
<select id="findGoodsVo" resultMap="goodsVoMap">
    select
      g.id,g.goods_name,g.goods_img,g.goods_detail,g.goods_price,g.goods_stock,
      sg.seckill_price,sg.stock_count,sg.start_date,sg.end_date
    from
      t_goods g
        LEFT JOIN
      t_seckill_goods as sg on g.id=sg.goods_id
  </select>

  <select id="findGoodsVoByGoodsId" resultMap="goodsVoMap" >
    select distinct
      g.id,g.goods_name,g.goods_img,g.goods_detail,g.goods_price,g.goods_stock,
      sg.seckill_price,sg.stock_count,sg.start_date,sg.end_date
    from
      t_goods g
        LEFT JOIN
      t_seckill_goods as sg on g.id=sg.goods_id
    where
      g.id = #{goodsId}
  </select>

Guess you like

Origin blog.csdn.net/kunAUGUST/article/details/119845461