映射文件的sql屬性:
id:標(biāo)識(shí)符(一般都是dao層方法名)
resultType:sql返回類型
resultMap:放回的映射類型
parameterType:參數(shù)類型
useGeneratedKeys="true" keyProperty="id":執(zhí)行完添加操作放回最后一次自增長(zhǎng)id(備注:把對(duì)象添加完后,對(duì)象的id屬性就自動(dòng)有值了)
resultMap高級(jí)映射:
超類(類中類)association:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
< resultMap type = "實(shí)體類類型" id = "標(biāo)識(shí)符" > < id property = "id" column = "id" /> < result property = "實(shí)體類屬性" column = "數(shù)據(jù)庫(kù)列" /> < result property = "屬性" column = "數(shù)據(jù)庫(kù)列" /> </ association > </ resultMap > |
一對(duì)多:collection
1
2
3
4
5
6
7
8
9
10
11
12
13
|
< resultMap type = "實(shí)體類類型" id = "標(biāo)識(shí)符" > < id property = "id" column = "id" /> < result property = "實(shí)體類屬性" column = "數(shù)據(jù)庫(kù)列" /> < collection property = "實(shí)體類集合對(duì)象" ofType = "集合類型" > < result property = "屬性" column = "數(shù)據(jù)庫(kù)列" /> </ collection > </ resultMap > |
以上這篇javaMybatis映射屬性,高級(jí)映射詳解就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持服務(wù)器之家。
原文鏈接:http://www.cnblogs.com/toplhh/archive/2017/11/12/7822320.html