详解Mybatis中的select方法
程序员文章站
2024-02-23 08:26:22
selectbyid方法
根据id,查询记录
public void updaterecycleassaybusinessitemcharge(string...
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方法,希望对大家有所帮助
上一篇: 父元素width为100%,设置padding,出现滚动条
下一篇: c#队列Queue学习示例分享