配置映射文件
<resultMap id="BaseResultMap" type="com.xxx.model.xxx" >
<!--WARNING - @mbggenerated
-->
<id column="USERID" property="userid" jdbcType="VARCHAR" />
<result column="ADDTIME" property="addtime" jdbcType="TIMESTAMP" />
<result column="ISDISABLE" property="isdisable" jdbcType="DECIMAL" />
<result column="ISTOP" property="istop" jdbcType="DECIMAL" />
<result column="SORTCODE" property="sortcode" jdbcType="DECIMAL" />
<collection column="USERID" property="itemList" javaType="List" ofType="com.xxx.model.Items" select="geItemsById"/>
</resultMap>
<select id="geItemsById" parameterType="String" resultType="com.xxx.model.Items">
select * from table where USERID=#{USERID}
</select>
实体类
@Column(name = "ISDISABLE")
private Short isdisable;
@Column(name = "ISTOP")
private Short istop;
@Column(name = "SORTCODE")
private Integer sortcode;
@Column(name = "INTRODUCE")
private String introduce;
//*****该对象对应的集合*****begin*****// @Transient -实体bean中所有的非static非@Transient都可以被持久化,除非你将其注解为@Transient。
@Transient
private List<Items> itemList=new ArrayList<Items>();
public List<Items> getItemList(){
return itemList;
}
public void setItemList(List<Items> itemList){
this.itemList=itemList;
}