永恒精魄,桂林九株浓缩液,小李获赠玫瑰金人
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方法,希望对大家有所帮助
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
浅析我对 String、StringBuilder、StringBuffer 的理解
使用IDEA搭建SSM框架的详细教程(spring + springMVC +MyBatis)
Springboot整合freemarker 404问题解决方案
引入mybatis-plus报 Invalid bound statement错误问题的解决方法
网友评论