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.dreamcloudprint.dao.mapper.TagMapper"> <resultMap id="BaseResultMap" type="com.dreamcloudprint.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.dreamcloudprint.dao.TagExtendMapper"> <select id="xxxxx" resultMap="com.dreamcloudprint.dao.mapper.TagMapper.BaseResultMap"> <!-- 这里时原始命名空间加上结果集id --> </select> </mapper>
或者是
<mapper namespace="com.dreamcloudprint.dao.TagExtendMapper"> <resultMap id="ExtBaseResultMap" type="com.dreamcloudprint.dao.Tag" extend="com.dreamcloudprint.dao.mapper.TagMapper.BaseResultMap"> ... </resultMap> </mapper>
个人笔记,价值不高,技术太菜,希望大家多多提意见,如果又什么更好的技术欢迎分享哦!
原文地址:https://www.cnblogs.com/51ctoedu/p/9460617.html
时间: 2024-10-10 09:51:08