实体类如下,bagNoList是String的List
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LineHaulPlateDTO implements Serializable {
private static final long serialVersionUID = 1091703593667681149L;
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private Integer aggregatorId;
private String lineHaulUuid;
private String plateNo;
private Integer bagCount;
private Double length;
private Double width;
private Double height;
private List<String> bagNoList = new ArrayList<>();
}
重点在于设置property和ofType
<resultMap id="LineHaulPlateAndBagNoMap" type="com.xxx.LineHaulPlateDTO">
<id column="ID" property="id" />
<result column="LINE_HAUL_UUID" property="lineHaulUuid" />
<result column="PLATE_NO" property="plateNo" />
<result column="BAG_COUNT" property="bagCount" />
<result column="LENGTH" property="length" />
<result column="WIDTH" property="width" />
<result column="HEIGHT" property="height" />
<collection property="bagNoList" ofType="java.lang.String">
<result column="BAG_NO"/>
</collection>
</resultMap>