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">

05-07 15:08