摘要: 有时候,我们在数据库中会插入一些字段的值时固定的,比如性别字段,它的值固定只有2个,男或者女; 或者季节字段,只有春夏秋冬4种。有时候在Java类中会采用枚举类型来表达相应的数据库字段,比如如下数据表: create table student( id int auto_increment comm 阅读全文
posted @ 2020-11-25 16:12 Hermioner 阅读(3704) 评论(0) 推荐(0) 编辑
摘要: 什么是一级缓存 在日常开发过程中,经常会有相同的sql执行多次查询的情况,mybatis提供了一级缓存来优化这些查询,避免多次请求数据库。 一级缓存在mybatis中默认是开启的并且是session级别,它的作用域为一次sqlSession会话。 什么是二级缓存 相对于一级缓存,二级缓存的作用域更广 阅读全文
posted @ 2020-11-25 15:03 Hermioner 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 概念这里不赘述了,上节都已介绍过了。 前提准备: 1 create table book( 2 id int auto_increment comment '书ID', 3 name varchar(50) comment '书名', 4 primary key(id)); 5 6 7 insert 阅读全文
posted @ 2020-11-25 14:58 Hermioner 阅读(450) 评论(0) 推荐(0) 编辑
摘要: mybatis3之后,采用了功能强大的OGNL表达式语言消除了许多其它繁琐的标签,现在动态SQL在xml中支持的几种标签: if choose(when、otherwise) trim(where、set) foreach bind 一.if标签 if标签通常用于where语句中,通过判断参数值来决 阅读全文
posted @ 2020-11-25 14:53 Hermioner 阅读(1109) 评论(0) 推荐(0) 编辑