如:
//旅游路线 public class Route { //A private int rid;//线路id,必输 private String rname;//线路名称,必输 ... //分类数据 private Category category; //B 一对一 association //商家数据 private Seller seller;//C 一对一 association //图片数据 private List<RouteImg> imgList; //集合 一对多 collection简化了特殊类型的成员变量的查询与赋值
<!-- 要对当前这个route内部的其他的成员变量进行查询与赋值 select 指定接口方法使用到的语句 property指定需要查询的数据 column 指定select方法需要的参数 select 指定需要调用的dao方法 --> <resultMap id="routeMap" type="route" autoMapping="true"> <association property="category" column="cid" select="com.wzx.dao.CategoryDao.findOneByCid" autoMapping="true"/> <association property="seller" column="sid" select="com.wzx.dao.SellerDao.findOneBySid" autoMapping="true"/> <collection property="imgList" column="rid" select="com.wzx.dao.RouteImgDao.findAllImgByRid" autoMapping="true"/> </resultMap>