映射文件的sql属性:
id:标识符(一般都是dao层方法名)
resultType:sql返回类型
resultMap:放回的映射类型
parameterType:参数类型
useGeneratedKeys="true" keyProperty="id":执行完添加操作放回最后一次自增长id(备注:把对象添加完后,对象的id属性就自动有值了)
resultMap高级映射:
超类(类中类)association:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
< resultMap type = "实体类类型" id = "标识符" > < id property = "id" column = "id" /> < result property = "实体类属性" column = "数据库列" /> < result property = "属性" column = "数据库列" /> </ association > </ resultMap > |
一对多:collection
1
2
3
4
5
6
7
8
9
10
11
12
13
|
< resultMap type = "实体类类型" id = "标识符" > < id property = "id" column = "id" /> < result property = "实体类属性" column = "数据库列" /> < collection property = "实体类集合对象" ofType = "集合类型" > < result property = "属性" column = "数据库列" /> </ collection > </ resultMap > |
以上这篇javaMybatis映射属性,高级映射详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:http://www.cnblogs.com/toplhh/archive/2017/11/12/7822320.html