1、resultMap、resultType、parameterType、parameterMap的区别:
https://www.cnblogs.com/fengli9998/p/7991032.html
2、#{}、${}的区别:
1、#{}将传入的数据都当成是一个字符串,会自动对传入的数据加上一个双引号
2、${}是一个替换的功能
3、#{}方式可以很大程度上防止sql注入
4、${}一般用于传入数据库对象,例如传入表名
5、MyBatis排序时使用order by 动态参数时需要注意,用${}而不是#{}
6、一般能用#{}就不用${}
3、date 和 timestamp的区别:
http://blog.sina.com.cn/s/blog_4c197d420101cmv3.html
4、配置多数据源的方式以及存在的问题(事务,并发)
5、resultMap标签的便利性,collection association 等的使用
collection是一对多
association是一对一
6、数据库插入操作返回自增主见id,使用useGenerateKeys和keyProperty属性:
<insert id="insertSelective" parameterType="cn.common.model.RepairFile" useGeneratedKeys="true" keyProperty="id">
insert into invt_repair_file
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="fileName != null" >
file_name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="fileName != null" >
#{fileName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
7、mybatis一级缓存 二级缓存
https://blog.csdn.net/acmman/article/details/46696265
如果是执行两次service调用查询相同 的用户信息,不走一级缓存,因为service方法结束,sqlSession就关闭,一级缓存就清空。这个时候就需要使用二级缓存,
使用一级缓存:
(1)添加@Transactional注解