详解Mybatis中的select方法
作者:刘培楠 时间:2023-06-10 05:44:49
selectById方法
根据id,查询记录
public void updateRecycleAssayBusinessItemCharge(String Id) {
AssayBusinessItemCharge assayBusinessItemCharge = assayBusinessItemChargeService.selectById(Id);
assayBusinessItemCharge.setRecordStatus(RecordStatusEnum.VALID.getValue());
assayBusinessItemChargeService.update(assayBusinessItemCharge);
}
selectByExample方法
根据实体字段,查询记录
public Account findByAccountName(String accountName) {
AccountExample accountExample = new AccountExample();
AccountExample.Criteria criteria = accountExample.createCriteria();
criteria.andAccountNameEqualTo(accountName);
List<Account> accountList = accountService.selectByExample(accountExample);
if (accountList == null || accountList.size() != 1)
return null;
else
return accountList.get(0);
}查询所有list
传一个空的实体,不要给赋字段值
public Account findByAccountName(String accountName) {
AccountExample accountExample = new AccountExample();
AccountExample.Criteria criteria = accountExample.createCriteria();
List<Account> accountList = accountService.selectByExample(accountExample);
if (accountList == null || accountList.size() != 1)
return null;
else
return accountList.get(0);
}
总结
以上所述是小编给大家介绍的Mybatis中的select方法网站的支持!
来源:https://blog.csdn.net/nangeali/article/details/81278822
标签:mybatis,select,方法
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#实现程序开机启动的方法
2023-09-23 00:55:20
深入理解java自旋锁
2023-10-28 00:32:49
Android自定义WaveProgressView实现水波纹加载需求
2021-07-29 02:06:00
![](https://img.aspxhome.com/file/2023/9/137729_0s.gif)
Java查找不重复无序数组中是否存在两个数字的和为某个值
2023-08-22 16:44:40
Springboot 扫描mapper接口的2种操作
2022-08-04 03:28:54
![](https://img.aspxhome.com/file/2023/6/73106_0s.jpg)
java虚拟机原理:Class字节码二进制文件分析
2022-02-06 09:02:33
![](https://img.aspxhome.com/file/2023/6/101946_0s.jpg)
rocketmq client 日志的问题处理方式
2023-07-15 08:10:32
![](https://img.aspxhome.com/file/2023/1/82461_0s.png)
Android实现全局悬浮框
2021-11-22 12:15:40
![](https://img.aspxhome.com/file/2023/5/111685_0s.jpg)
逆转交替合并两个链表的解析与实现
2021-12-31 12:37:41
![](https://img.aspxhome.com/file/2023/2/88752_0s.png)
spring 整合mybatis后用不上session缓存的原因分析
2021-12-09 10:11:03
解决RedisTemplate存储至缓存数据出现乱码的情况
2023-04-20 15:30:58
![](https://img.aspxhome.com/file/2023/8/92718_0s.jpg)
java实现上传图片尺寸修改和质量压缩
2023-04-04 03:42:55
Spring Security中使用authorizeRequests遇到的问题小结
2023-10-07 04:23:45
![](https://img.aspxhome.com/file/2023/2/64952_0s.png)
c++代码调试方式的几点建议
2023-07-05 05:31:35
详解Spring Boot中使用AOP统一处理Web请求日志
2021-08-24 15:50:17
Java文件操作之IO流 File类的使用详解
2023-07-26 00:49:41
java 实现将一个string保存到txt文档中
2022-07-30 05:32:38
Lombok为啥这么牛逼?SpringBoot和IDEA官方都要支持它
2021-10-18 23:04:50
![](https://img.aspxhome.com/file/2023/7/64497_0s.png)
Java简单计时的实现案例(可以用来限时循环)
2023-02-01 21:39:19
Java 实现协程的方法
2022-02-18 22:55:05