<resultMap/> 标签支持继承 extends

一、Java代码

public class CocBean {
    private String name;
    private Double volume;
    //get() / set()
}
public class CocTreeNode extends CocBean {
    private String level1;
    private String level2;
    //get() and set()
}

二、XML Mapper

<resultMap id="CocBeanResult" type="CocBean">  
    <result property="name" column="NAME"/>  
    <result property="volume" column="VOLUME"/>  
</resultMap>
<resultMap id="simpleRow" type="CocTreeNode" extends="CocBeanResult">  
    <result property="level1" column="LEVEL1"/>  
    <result property="level2" column="LEVEL2"/>  
</resultMap>

猜你喜欢

转载自www.cnblogs.com/yifanSJ/p/9096097.html