TK.Mybatis查询方法
一、概述
本章节基于第一章节的:01.Mybatis Tk插件环境搭建
TK的内置查询方法有很多,在该章节主要介绍几种常用的的方法:
- selectAll():查询所有
- selectByPrimaryKey(Object var1):主键查询
- selectByExample(Example example):用来复杂查询
二、单元测试
- 主键查询
它会根据主键进行查询,进行传的是一个对象,它只会拼接主键。
@Test
public void selectAll(){
Product param = new Product();
param.setId(1L);
param.setProductName("Redis深度历险记");
//Product product = productDao.selectByPrimaryKey(1L); 等价下面语句
Product product = productDao.selectByPrimaryKey(param);
}