其他分享
首页 > 其他分享> > TKMybatis 的使用方法

TKMybatis 的使用方法

作者:互联网

 

操作 类型 介绍
增加 Mapper.insert(record) 保存一个实体,null的属性也会保存,不会使用数据库默认值
Mapper.insertSelective(record) 保存一个实体,忽略空值,即没提交的值会使用使用数据库默认值
 
删除 Mapper.delete(record) 根据实体属性作为条件进行删除,查询条件使用等号
Mapper.deleteByExample(example) 根据Example条件删除数据
Mapper.deleteByPrimaryKey(key) 根据主键字段进行删除,方法参数必须包含完整的主键属性
 
修改 Mapper.updateByExample(record,example) 根据Example条件更新实体`record`包含的全部属性,null值会被更新
Mapper.updateByExampleSelective(record, example) 根据Example条件更新实体`record`包含的不是null的属性值
Mapper.updateByPrimaryKey(record) 根据主键更新实体全部字段,null值会被更新
Mapper.updateByPrimaryKeySelective(record) 根据主键更新属性不为null的值
 
查询 Mapper.select(record) 根据实体中的属性值进行查询,查询条件使用等号
Mapper.selectAll() 查询全部结果
Mapper.selectByExample(example) 根据Example条件进行查询
Mapper.selectByPrimaryKey(key) 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号
Mapper.selectCount(record) 根据实体中的属性查询总数,查询条件使用等号
Mapper.selectCountByExample(example) 根据Example条件进行查询总数
Mapper.selectOne(record)

根据实体中的属性进行查询,只能有一个返回值,

有多个结果是抛出异常,查询条件使用等号。

但是如果存在某个属性为int,则会初始化为0。可能影响到实际使用

标签:Mapper,TKMybatis,实体,查询,record,使用,方法,主键,属性
来源: https://www.cnblogs.com/luchenglong/p/15814053.html