mybatis getone
时间: 2023-11-12 10:04:28 浏览: 111
MyBatis中的getOne方法是用来查询一条数据的。如果查询结果有多条数据,会报错。要么使用其他方法,要么只选择其中一条数据。可以在条件构造器Wrapper的结尾加上.last("limit 1")来只选择一条(第一条)数据。\[1\]
例如,在使用getOne方法时,可以这样写:
getOne(Wrappers.<CdOrderBoxDoorPointRef>lambdaQuery().eq(CdOrderBoxDoorPointRef::getOrderBoxId,boxIds.get(0)).last("limit 1"));\[2\]
#### 引用[.reference_title]
- *1* *2* [mybatisPlus中getOne方法如何只取其中一条数据(Wrapper有多条数据时)](https://blog.csdn.net/qq_43907515/article/details/118909940)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Mybatis-Plus中getOne方法获取最新一条数据](https://blog.csdn.net/weixin_46146718/article/details/128019795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文