没有合适的资源?快使用搜索试试~ 我知道了~
MyBatis个人笔记
资源推荐
资源详情
资源评论
使用方法:直接就可以获取到
1.3如果实体类属性(驼峰命名法)和数据库属性(不区分大小
写,用下划线)命名不一致,解决办法。
方案一: 给字段起别名, 让别名与实体类属性一致,第二行就是别名。
方案二: 通过@Results, @Result注解手动映射封装。一个@Result对应封装一个。
方案三:开启驼峰命名自动映射开关,a_cloumn ------> aColumn
@Select("select id, username, password, name, gender, image, job, entrydate, " +
"dept_id deptId, create_time createTime, update_time updateTime from emp where id = #
{id}")
public Emp getById(Integer id);
@Results({
@Result(column = "dept_id", property = "deptId"),
@Result(column = "create_time", property = "createTime"),
@Result(column = "update_time", property = "updateTime")
})
@Select("select * from emp where id = #{id}")
public Emp getById(Integer id);
collection:遍历的集合
item:遍历出来的元素
separator:分隔符
open:遍历前拼接的字符串
close:遍历后拼接的字符串
1.6动态SQL抽取重复select语句
这段代码是重复的,抽取出来每次加上即可。
1.7分页查询插件PageHelper
进行分页查询普通操作:
传入两个值,页数和每页大小。
引入插件后操作,先引入maven,只需要配置PageHelper的开始和页面大小,使用select * from table就可以完成
条件查询。
select id, username, password, name, gender, image, job, entrydate, dept_id, create_time,
update_time
from emp
剩余16页未读,继续阅读
资源评论
Aa_bandon
- 粉丝: 9
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功