詳解Mybatis中的select方法
selectById方法
根據(jù)id,查詢記錄
public void updateRecycleAssayBusinessItemCharge(String Id) {
AssayBusinessItemCharge assayBusinessItemCharge = assayBusinessItemChargeService.selectById(Id);
assayBusinessItemCharge.setRecordStatus(RecordStatusEnum.VALID.getValue());
assayBusinessItemChargeService.update(assayBusinessItemCharge);
}
selectByExample方法
根據(jù)實(shí)體字段,查詢記錄
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);
}
查詢所有l(wèi)ist
傳一個(gè)空的實(shí)體,不要給賦字段值
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);
}
總結(jié)
以上所述是小編給大家介紹的Mybatis中的select方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
Spring學(xué)習(xí)通過AspectJ注解方式實(shí)現(xiàn)AOP操作
這篇文章主要為大家介紹了Spring學(xué)習(xí)通過AspectJ注解方式實(shí)現(xiàn)AOP操作,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05
springBoot+mybatis-plus實(shí)現(xiàn)監(jiān)聽mysql數(shù)據(jù)庫的數(shù)據(jù)增刪改
mybatis-plus技術(shù)是簡化了繁瑣的代碼操作,把增刪改查的語句都內(nèi)置了,直接調(diào)用就可以實(shí)現(xiàn)數(shù)據(jù)庫的增刪改查了,這篇文章主要給大家介紹了關(guān)于springBoot+mybatis-plus實(shí)現(xiàn)監(jiān)聽mysql數(shù)據(jù)庫數(shù)據(jù)增刪改的相關(guān)資料,需要的朋友可以參考下2024-01-01
Java中的日期和時(shí)間類以及Calendar類用法詳解
這篇文章主要介紹了Java中的日期和時(shí)間類以及Calendar類用法詳解,是Java入門學(xué)習(xí)中的基礎(chǔ)知識,需要的朋友可以參考下2015-09-09
詳解如何配置Spring Batch批處理失敗重試機(jī)制
這篇文章主要來和大家一起探討一下如何在Spring批處理框架中配置重試邏輯,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-06-06
springboot項(xiàng)目防止XSS攻擊和sql注入方式
這篇文章主要介紹了springboot項(xiàng)目防止XSS攻擊和sql注入方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-07-07
在Ubuntu系統(tǒng)下安裝JDK和Tomcat的教程
這篇文章主要介紹了在Ubuntu系統(tǒng)下安裝JDK和Tomcat的教程,這樣便是在Linux系統(tǒng)下搭建完整的Java和JSP開發(fā)環(huán)境,需要的朋友可以參考下2015-08-08

