mybatis知識點(已掌握)

2022-09-14 14:42:08 字數 653 閱讀 3687

1.${} 和 #{} 的區別?

${} 直接顯示傳入資料,不能防止sql注入,一般用於傳資料庫物件(比如表名)。

#{} 傳入資料被當成字串,自動加上雙引號,防止sql注入。

2.有哪些executor?區別?

******executor:每執行一次update或select,就開啟乙個statement物件,用完立刻關閉statement物件。

reuseexecutor執行update或select,以sql作為key查詢statement物件,存在就使用,不存在就建立,用完後,不關閉statement物件,而是放置於map內,供下一次使用。簡言之,就是重複使用statement物件。

batchexecutor執行update(沒有select,jdbc批處理不支援select),將所有sql都新增到批處理中(addbatch()),等待統一執行(executebatch()),它快取了多個statement物件,每個statement物件都是addbatch()完畢後,等待逐一執行executebatch()批處理。與jdbc批處理相同。

作用範圍:executor的這些特點,都嚴格限制在sqlsession生命週期範圍內。

mybatis知識點總結

1 resultmap resulttype parametertype parametermap的區別 2 的區別 1 將傳入的資料都當成是乙個字串,會自動對傳入的資料加上乙個雙引號 2 是乙個替換的功能 3 方式可以很大程度上防止sql注入 4 一般用於傳入資料庫物件,例如傳入表名 5 myba...

Mybatis小知識點

select from user and username like and 2 foreach標籤 select from user and username like and 3 selectkey標籤 select last insert id insert into user usernam...

mybatis總結的知識點

原始碼中configuration這個類是解析所有配置檔案的 有幾種執行器 executortype中有三種列舉型別 simpe簡單的 預設的 reuse復用的 batch批量的 預設的一級快取是開啟的還是關閉的 在configuration中有乙個cacheenabled true 這個開啟後就開...