一对多的关系
<resultMap type="Person" id="personBean"> <id column="personId" property="id"/> <result column="personName" property="name"/> <result column="personAddress" property="address"/> <result column="personTel" property="tel"/> <!-- 一对多的关系 --> <!-- property: 指的是集合属性的值, ofType:指的是集合中元素的类型 --> <collection property="orders" ofType="Order"> <id column="orderId" property="id"/> <result column="orderNumber" property="number"/> <result column="orderPrice" property="price"/> </collection> </resultMap> <resultMap type="Order" id="orderBean"> <id column="orderId" property="id"/> <result column="orderNumber" property="number"/> <result column="orderPrice" property="price"/> <!-- 多对一的关系 --> <!-- property: 指的是属性的值, javaType:指的是属性的类型--> <association property="person" javaType="Person"> <id column="personId" property="id"/> <result column="personName" property="name"/> <result column="personAddress" property="address"/> <result column="personTel" property="tel"/> </association> </resultMap>