① 主键列可以是<id column="id" property="id"/> 或 <result column="id" property="id"/>
② 一对一查询推荐使用public class Xxx implements Serializable { private Xxx propertyName; getter; setter; }
映射配置文件中使用<association property="propertyName" column="dbColumn" javaType="entityNameIgnoreCase"></association>
③ 多对多查询推荐使用public class Xxx implements Serializable { private List<Xxx> listName; getter; setter; }
映射配置文件中使用<collection property="listName" ofType="entityNameIgnoreCase"></collection>
- 通过建立实体类关系的方式实现一对一关系的查询(推荐使用),定义的resultMap必须有对应的引用,否则查询结果为null。
- 通过主表实体对应从表实体的集合引用实现一对多关系的查询。
- 通过在一个类中引用另一个类的集合实现基于左外连接的多对多关系查询。