maskice 2022-06-25 10:47 采纳率: 0%
浏览 26

mybatis的resultMap如何重用?

resultMap可以重用吗?我现在有2个resultMap,一个是列表时候用的不关联其他表,一个是详情用的关联了其他表
 <resultMap id="BaseResultMap" type="ShopTypeProperty">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="goods_group_id" jdbcType="VARCHAR" property="goodsGroupId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="type" jdbcType="INTEGER" property="type" />
    <result column="show_type" jdbcType="INTEGER" property="showType" />
    <result column="require_flag" jdbcType="SMALLINT" property="requireFlag" />
    <result column="search_flag" jdbcType="SMALLINT" property="searchFlag" />
    <result column="sort" jdbcType="INTEGER" property="sort" />
    <result column="create_at" jdbcType="TIMESTAMP" property="createAt" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_at" jdbcType="TIMESTAMP" property="updateAt" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
  </resultMap>
  <resultMap id="AllResultMap" type="ShopTypeProperty">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="goods_group_id" jdbcType="VARCHAR" property="goodsGroupId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="type" jdbcType="INTEGER" property="type" />
    <result column="show_type" jdbcType="INTEGER" property="showType" />
    <result column="require_flag" jdbcType="SMALLINT" property="requireFlag" />
    <result column="search_flag" jdbcType="SMALLINT" property="searchFlag" />
    <result column="sort" jdbcType="INTEGER" property="sort" />
    <result column="create_at" jdbcType="TIMESTAMP" property="createAt" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_at" jdbcType="TIMESTAMP" property="updateAt" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <association property="goodsGroup" javaType="ShopGoodsGroup">
      <id column="goods_group_id" property="id"/><!-- 外键映射 -->
      <result column="name" property="name"/>
      <result column="sort" property="sort"/>
    </association>
    <collection property="values" ofType="ShopTypePropertyValue">
      <id column="goods_property_id" property="id"/><!-- 外键映射 -->
      <result column="val" property="val"/>
      <result column="valSort" property="sort"/>
    </collection>
  </resultMap>

以下代码在 id="AllResultMap" 如何重用?有类似include之类的吗
<id column="id" jdbcType="VARCHAR" property="id" />
    <result column="goods_group_id" jdbcType="VARCHAR" property="goodsGroupId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="type" jdbcType="INTEGER" property="type" />
    <result column="show_type" jdbcType="INTEGER" property="showType" />
    <result column="require_flag" jdbcType="SMALLINT" property="requireFlag" />
    <result column="search_flag" jdbcType="SMALLINT" property="searchFlag" />
    <result column="sort" jdbcType="INTEGER" property="sort" />
    <result column="create_at" jdbcType="TIMESTAMP" property="createAt" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_at" jdbcType="TIMESTAMP" property="updateAt" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />

  • 写回答

1条回答 默认 最新

报告相同问题?

问题事件

  • 创建了问题 6月25日

悬赏问题

  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示