selectById方法
根據(jù)id,查詢記錄
public void updateRecycleAssayBusinessItemCharge(String Id) { AssayBusinessItemCharge assayBusinessItemCharge = assayBusinessItemChargeService.selectById(Id); assayBusinessItemCharge.setRecordStatus(RecordStatusEnum.VALID.getValue()); assayBusinessItemChargeService.update(assayBusinessItemCharge);}
selectByExample方法
根據(jù)實體字段,查詢記錄
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
傳一個空的實體,不要給賦字段值
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方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對VeVb武林網(wǎng)網(wǎng)站的支持!
新聞熱點
疑難解答
圖片精選