<resultMap type="com.xx.xx.UerInfo" id="userInfoResult"> <result property="name" column="name"/> <!--association可以指定联合的javaBean对象 property="dept":指定哪个属性是联合的对象 javaType:指定这个属性对象的类型 --> <association property="dept" column="dept_id" javaType="com.xx.xx.DeptInfo" /> <!--collection 可以指定联合的javaBean对象 property="roles":指定哪个属性是联合的对象 javaType:指定这个属性对象的类型 --> <collection property="roles" javaType="java.util.List" resultMap="com.xx.xx.RoleInfo" /> <!--ofType:指定的是映射到list集合属性中POJO的类型 --> <collection property="projects" javaType="java.util.List" ofType="ProjectResult"> <result property="projectType" column="project_type"/> </collection> </resultMap>
标签resultmap实现字段名映射属性名;
标签association实现一对一级联查询;
标签collection 实现一对多级联查询;