DefaultSqlSessionFactory源碼

I always like to start with the field.sometimes you can learn it's purpose from it's naming.even if it's hard to understand,you can just remember it.then you just go on.
no more word,just watch this picture.

field and constructor.png

ok,this class only hava one field.the configuration saves all the data which passed from the xml file.and just as you can see,there is only one contructor and it's very simple.just make the field configuration point to the parameter configuration.
so next ,we analyse the following method.

openSession.png

there are so many overloaded function.i just capture some.Generally speaking they invoke the two main function called openSessionFromDataSource and openSessionFromConnection.

openSessionFromConnection.png
openSessionFromDataSource.png

ok,here is the function.list the things it will do:
first,get environment from configuration.(when we parse the xml file,we had already save this info into configuration,so just take it out)
second,get transactionFactory from environment.(because in the xml file,we have transaction node under the environment node)
third,use transactionFactory to create a new transaction.(according to the different type,choose different implemation to achive the transactional goal)
forth,use transaction and execType to get a new executor,which is the most impotant thing in execute the sql.
fifth,return a new defaultSqlSession.
that's all.
end.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末闷祥,一起剝皮案震驚了整個(gè)濱河市娱颊,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖维蒙,帶你破解...
    沈念sama閱讀 221,635評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件掰吕,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡颅痊,警方通過查閱死者的電腦和手機(jī)殖熟,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,543評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來斑响,“玉大人菱属,你說我怎么就攤上這事〗⒎#” “怎么了纽门?”我有些...
    開封第一講書人閱讀 168,083評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長营罢。 經(jīng)常有香客問我赏陵,道長,這世上最難降的妖魔是什么饲漾? 我笑而不...
    開封第一講書人閱讀 59,640評(píng)論 1 296
  • 正文 為了忘掉前任蝙搔,我火速辦了婚禮,結(jié)果婚禮上考传,老公的妹妹穿的比我還像新娘吃型。我一直安慰自己,他們只是感情好僚楞,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,640評(píng)論 6 397
  • 文/花漫 我一把揭開白布勤晚。 她就那樣靜靜地躺著,像睡著了一般泉褐。 火紅的嫁衣襯著肌膚如雪赐写。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,262評(píng)論 1 308
  • 那天膜赃,我揣著相機(jī)與錄音血淌,去河邊找鬼。 笑死财剖,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的癌淮。 我是一名探鬼主播躺坟,決...
    沈念sama閱讀 40,833評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼乳蓄!你這毒婦竟也來了咪橙?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,736評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎美侦,沒想到半個(gè)月后产舞,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,280評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡菠剩,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,369評(píng)論 3 340
  • 正文 我和宋清朗相戀三年易猫,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片具壮。...
    茶點(diǎn)故事閱讀 40,503評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡准颓,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出棺妓,到底是詐尸還是另有隱情攘已,我是刑警寧澤,帶...
    沈念sama閱讀 36,185評(píng)論 5 350
  • 正文 年R本政府宣布怜跑,位于F島的核電站样勃,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏性芬。R本人自食惡果不足惜峡眶,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,870評(píng)論 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望批旺。 院中可真熱鬧幌陕,春花似錦、人聲如沸汽煮。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,340評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽暇赤。三九已至心例,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間鞋囊,已是汗流浹背止后。 一陣腳步聲響...
    開封第一講書人閱讀 33,460評(píng)論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留溜腐,地道東北人译株。 一個(gè)月前我還...
    沈念sama閱讀 48,909評(píng)論 3 376
  • 正文 我出身青樓,卻偏偏與公主長得像挺益,于是被迫代替她去往敵國和親歉糜。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,512評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容