根據(jù)id,查詢記錄
1
2
3
4
5
|
public void updaterecycleassaybusinessitemcharge(string id) { assaybusinessitemcharge assaybusinessitemcharge = assaybusinessitemchargeservice.selectbyid(id); assaybusinessitemcharge.setrecordstatus(recordstatusenum.valid.getvalue()); assaybusinessitemchargeservice.update(assaybusinessitemcharge); } |
selectbyexample方法
根據(jù)實體字段,查詢記錄
1
2
3
4
5
6
7
8
9
10
|
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
傳一個空的實體,不要給賦字段值
1
2
3
4
5
6
7
8
9
|
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方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務(wù)器之家網(wǎng)站的支持!
原文鏈接:https://blog.csdn.net/nangeali/article/details/81278822