实体类
public class User {
resultMap //collectiom只能在最好一条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 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