mybatis resultMap使用

<!--获取商品列表-->
  <resultMap id="goodsVoMap" type="com.example.seckill.vo.GoodsVo">
    <id column="id" jdbcType="BIGINT" property="id"/>
    <result column="goods_name" jdbcType="VARCHAR" property="goodsName"/>
    <result column="goods_img" jdbcType="VARCHAR" property="goodsImg"/>
    <result column="goods_detail" jdbcType="VARCHAR" property="goodsDetail"/>
    <result column="goods_price" jdbcType="DECIMAL" property="goodsPrice"/>
    <result column="goods_stock" jdbcType="DECIMAL" property="goodsStock"/>
    <result column="seckill_price" jdbcType="DECIMAL" property="seckillPrice"/>
    <result column="stock_count" jdbcType="INTEGER" property="stockCount"/>
    <result column="start_date" jdbcType="INTEGER" property="startDate"/>
    <result column="end_date" jdbcType="INTEGER" property="endDate"/>
  </resultMap>
  <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>

注意事项
1.jdbcType必须大写
2.部分jdbctype类型和sql类型对应:

jdbc type sql
INTEGER int
VARCHAR LongText

猜你喜欢

转载自blog.csdn.net/kunAUGUST/article/details/119842831