mybatis入參方式和緩沖
阿新 • • 發佈:2017-11-21
方式 password 映射文件 cati ado true readonly interval pda
1.mybatis入參方式
@Param註解參數(註解)
封裝成對象入參
public int updatePassword(@Param("id")int id,@Param("pwd")String newpwd);
註意:一般情況下:參數超過3個,就用對象.
2.MyBatis緩存
1).分類
一級緩存:SqlSession級別的緩存.(在同一個SqlSession中,緩存有效,默認打開)
二級緩存:應用級別緩存(全局緩存,隨便在哪裏都能取得到.默認是關閉的)
2)打開全局緩存
第一步:配置mybatis核心配置文件
<setting name="cacheEnabled" value="true"/>
第二步:單獨開啟映射文件的緩存
<cache eviction="FIFO" flushInterval="60000" size="512" readOnly="true"/>
evication:表示溢出處理機制.
獨立設置某一條sql的緩存
<select id="selectAll" resultType="Emp"
useCache="true">
mybatis入參方式和緩沖