zoukankan      html  css  js  c++  java
  • Mybatis的XML映射文件的继承问题

    1.首先dao层mapper.java需要继承原来的接口

      原dao层接口

    public interface TagMapper {
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table t_tag
         *
         * @mbg.generated
         */
        long countByExample(TagExample example);
    
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table t_tag
         *
         * @mbg.generated
         */
        int deleteByExample(TagExample example);
    }

      扩展后的dao层接口

    public interface TagExtendMapper extends TagMapper {
        ...
    }

    2.继承原始mapper.xml的结果映射 

      原始mapper.xml的结果映射

    <mapper namespace="com.xxx.dao.mapper.TagMapper">
      <resultMap id="BaseResultMap" type="com.xxx.dao.Tag">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="id" jdbcType="CHAR" property="id" />
        <result column="tag_name" jdbcType="VARCHAR" property="tagName" />
        <result column="tag_alias" jdbcType="VARCHAR" property="tagAlias" />
      </resultMap>
    </mapper>

      扩展mapper.xml的结果映射

    <mapper namespace="com.xxx.dao.TagExtendMapper">
        <select id="xxxxx" resultMap="com.xxx.dao.mapper.TagMapper.BaseResultMap"> <!-- 这里时原始命名空间加上结果集id -->
        </select>
    </mapper>

      或者是

    <mapper namespace="com.xxx.dao.TagExtendMapper">
       <resultMap id="ExtBaseResultMap" type="com.xxx.dao.Tag" extend="com.xxx.dao.mapper.TagMapper.BaseResultMap">
           ...
      </resultMap>
    </mapper>

     个人笔记,价值不高,技术太菜,希望大家多多提意见,如果又什么更好的技术欢迎分享哦!

  • 相关阅读:
    Mysql事务的隔离级别,ACID以及三要素的取舍(强一致性弱一致性)、ABA问题
    符合python风格的对象
    python重载运算符之左add右add(radd)
    pycham快捷键
    设置linux时间同步
    描述克隆linux的步骤,以及后续配置
    linux命令
    ransientException: find no Route:SELECT * FROM `ego`.`tb_content_category` LIMIT 0,1000‘
    linux修改vim /etc/profile 配置文件 修改不了
    web.xml
  • 原文地址:https://www.cnblogs.com/51ctoedu/p/9460617.html
Copyright © 2011-2022 走看看