With Mbgenerator automatically generating MyBatis entities and Mapper (XML and interface) files, if you want to add new operations to the mapper, it is not convenient to change the automatically generated files, the workaround is to define a new interface and a new mapper XML file.
Blogextmapper.java
Public interface Blogextmapper extends Blogmapper {list<blog> selectall (); List<blog> selectrecent (); List<blog> selectbyyearmonth (String yearmonth); List<blog> selectactiveblogs (); List<blog> selectbestblogs (); List<blogstatistic> Groupbyyearmonth (); list<blog> selectblogsbycategory (int categoryid); list<blog> selectblogsbyrange (int offset);}
The select operation that corresponds to the new XML definition and interface method.
Blogextmapper.xml:
<mapper namespace= "Com.icool.cms.data.mybatis.extend.BlogExtMapper" > <resultmap id= "Groupbyyearmonthmap" type= "com.icool.cms.data.mybatis.BlogStatistic" > <result column= "C" property= "Count" jdbcType= " INTEGER " /> <result column=" y " property=" Year " jdbctype=" VARCHAR " /> <result column" = "M" property= "month" jdbctype= "VARCHAR" /> </resultMap> <select id= "SelectAll" resultmap= " Com.icool.cms.data.mybatis.BlogMapper.ResultMapWithBLOBs "> select <include refid= " Com.icool.cms.data.mybatis.BlogMapper.Base_Column_List " /> , <include refid= "Com.icool.cms.data.mybatis.BlogMapper.Blob_Column_List" /> from BLOG order by Createtime desc </select>, .....
The main point of attention here is how to reuse some of the resultmap defined in Blogmapper.xml, which is very simple, with the full package name:
Com.icool.cms.data.mybatis.BlogMapper.ResultMapWithBLOBs
Extension of mapper in MyBatis