Mybatis resultMap支持继承

一、代码

映射domain为继承关系

public class CocTreeNode extends CocBean implements TreeNode {

  private String level1, level2;

  public void setLevel1(String level1){...}
  public void setLevel2(String level2){...}

  public String getLevel1(){...}
  public String getLevel1(){...}

}

public class CocBean {

  protected String name;
  protected Double volume;

  public void setName(String name){...}
  public void setVolume(Double volume){...}

  public String getName(){...}
  public Double getVolume(){...}

}

二、映射xml文件

利用resultMap的extends属性。


    
    



    
    



参考:

http://stackoverflow.com/questions/13734779/mybatis-inherited-properties-not-being-mapped

你可能感兴趣的:(mybatis)