详解Mybatis中的select方法

网友投稿 290 2023-01-24


详解Mybatis中的select方法

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 accountList = accountService.selectByExample(accountExample);

if (accountList == null || accountList.size() != 1)

return null;

else

return accountList.get(0);

}

查询所有list

传http://一个空的实体,不要给赋字段值

public Account findByAccountName(String accountName) {

AccountExample accountExample = new AccountExample();

AccountExample.Criteria criteria = accountExample.createCriteria();

List accountList = accountService.selectByExample(accountExample);

if (accountList == null || accountList.size() != 1)

return null;

else

return accountList.get(0);

}

总结

以上所述是给大家介绍的Mybatis中的select方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,会及时回复大家的。在此也非常感谢大家对我们网站的支持!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:spring 自动装配和aop的使用
下一篇:数据共享文件系统(数据库文件共享)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~