|
|
@ -411,7 +411,37 @@ public class ResultMapping {
|
|
|
|
private boolean lazy;
|
|
|
|
private boolean lazy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
另一个比较重要的类是ResultMap,每个<resultMap>节点都会被解析成一个ResultMap对象,其中每个节点所定义的映射关系,则使用ResultMapping对象表示。
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
|
|
|
public class ResultMap {
|
|
|
|
|
|
|
|
private Configuration configuration;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 这些属性一一对应了<resultMap>中的属性
|
|
|
|
|
|
|
|
private String id;
|
|
|
|
|
|
|
|
private Class<?> type;
|
|
|
|
|
|
|
|
// 记录了除<discriminator>节点之外的其它映射关系(即,ResultMapping对象集合)
|
|
|
|
|
|
|
|
private List<ResultMapping> resultMappings;
|
|
|
|
|
|
|
|
// 记录了映射关系中带有ID标志的映射关系,如:<id>节点和<constructor>节点的<idArg>子节点
|
|
|
|
|
|
|
|
private List<ResultMapping> idResultMappings;
|
|
|
|
|
|
|
|
// 记录了映射关系中带有Constructor标志的映射关系,如:<constructor>所有子元素
|
|
|
|
|
|
|
|
private List<ResultMapping> constructorResultMappings;
|
|
|
|
|
|
|
|
// 记录了映射关系中不带有Constructor标志的映射关系
|
|
|
|
|
|
|
|
private List<ResultMapping> propertyResultMappings;
|
|
|
|
|
|
|
|
// 记录了所有映射关系中涉及的column属性的集合
|
|
|
|
|
|
|
|
private Set<String> mappedColumns;
|
|
|
|
|
|
|
|
// 记录了所有映射关系中涉及的property属性的集合
|
|
|
|
|
|
|
|
private Set<String> mappedProperties;
|
|
|
|
|
|
|
|
// 鉴别器,对应<discriminator>节点
|
|
|
|
|
|
|
|
private Discriminator discriminator;
|
|
|
|
|
|
|
|
// 是否含有嵌套的结果映射,如果某个映射关系中存在resultMap属性,
|
|
|
|
|
|
|
|
// 且不存在resultSet属性,则为true
|
|
|
|
|
|
|
|
private boolean hasNestedResultMaps;
|
|
|
|
|
|
|
|
// 是否含有嵌套查询,如果某个属性映射存在select属性,则为true
|
|
|
|
|
|
|
|
private boolean hasNestedQueries;
|
|
|
|
|
|
|
|
// 是否开启自动映射
|
|
|
|
|
|
|
|
private Boolean autoMapping;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
### 3.2 解析<sql>节点
|
|
|
|
### 3.2 解析<sql>节点
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|