随笔分类 - Mybatis
Mybatis相关文件
摘要:mapper文件中返回主键: 在service层,调用这个方法后,根据getId方法可以获取主键。但在web层,controller的方法里,却获取的是null。 原因:web层和service层是通过dubbo调用的,其对象不是同一个,故获取不到主键。 解决方法:在service层返回主键,web
阅读全文
摘要:一级缓存基于 PerpetualCache 的 HashMap 本地缓存,其存储作用域为 Session,当 Session flush 或 close 之后,该Session中的所有 Cache 就将清空。 二级缓存与一级缓存其机制相同,默认也是采用 PerpetualCache,HashMap
阅读全文
摘要:一、Redis环境 Redis 官网 :http://redis.io/ windows下载:https://github.com/dmajkic/redis/downloads 1、文件解压缩 2、启动Redis服务器 3、启动Redis客户端 4、测试Redis缓存 redis-cli.exe
阅读全文
摘要:最近做的项目发现没有中文注释,故查找资料,特此记录。 本文所用的是基于mybatis-generator 1.3.2版本来完成的。 mybatis-generator 自动生成的代码注释是很反人类的,通常我们在使用的时候都是按照如下设置关闭注释: 不过在mybatis-generator官方文档中c
阅读全文
摘要:<select id="getCount" resultType="int"> select count(1) from <choose> <when test='type!=null and type=="2"'> (或者<when test="type!=null and type=='2'.t
阅读全文
摘要:JDBC Type Java Type CHAR String VARCHAR String LONGVARCHAR String NUMERIC java.math.BigDecimal DECIMAL java.math.BigDecimal BIT boolean BOOLEAN boolea
阅读全文
摘要:1.对应的xml文件:<!--批量添加--><insert id="insertStandardItemInfo" parameterType="hashmap"> insert into t_standard_item(standard_id,item_id) values <foreach co
阅读全文
摘要:foreach元素的属性主要有 item,index,collection,open,separator,close。 item表示集合中每一个元素进行迭代时的别名. (直接找到对应的delList集合里面的所有元素,item="item"中的item(后一个)必须与#{item} 中的item一致
阅读全文