[size=medium]
[color=green]//实体类[/color]
Document.java
private Long id;
private String title;
……
[color=green]//返回的结果集[/color]
<resultMap class="document" id="documentResult">
<result property="id" column="id"/>
<result property="title" column="title"/>
</resultMap>
[color=green]// 具体的查询sql[/color]
<select id="findDoc">
select id, title from document
</select>
[color=red]1.实体类Document中声明的属性必须将documentResult声明的字段覆盖完,可以声明documentResult中没有的字段。
2.documentResult中声明的字段必须和具体的sql语句,select 后的字段一一对应,否则出错。[/color]
[/size]
[color=green]//实体类[/color]
Document.java
private Long id;
private String title;
……
[color=green]//返回的结果集[/color]
<resultMap class="document" id="documentResult">
<result property="id" column="id"/>
<result property="title" column="title"/>
</resultMap>
[color=green]// 具体的查询sql[/color]
<select id="findDoc">
select id, title from document
</select>
[color=red]1.实体类Document中声明的属性必须将documentResult声明的字段覆盖完,可以声明documentResult中没有的字段。
2.documentResult中声明的字段必须和具体的sql语句,select 后的字段一一对应,否则出错。[/color]
[/size]