mybatis 映射 List

实体类
 
public class User {
    private String id;
    private String name;
    private List<String> otherName;
 

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<String> getOtherName() {
        return otherName;
    }

    public void setOtherName(List<String> loginName) {
        this.otherName= otherName;
    }
}
  

resultMap //collectiom只能在最好一条
 
 

  <resultMap id="UserMap" type="com.User" extends="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <result column="id" jdbcType="CHAR" property="id"/>
    <collection property="otherName" ofType="java.lang.String" >
      <result column="oName"/>
    </collection>
  </resultMap>


 
 

记录如下

      id   name oName

        1   aa  b

       1    aa  c

       2    bb  d



猜你喜欢

转载自blog.csdn.net/qdqht2009/article/details/78331451