选择方法怎么在Mybatis中使用

  

选择方法怎么在Mybatis中使用?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

<强> 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 帐号名称),{   AccountExample 才能;AccountExample =, new  AccountExample ();   AccountExample.Criteria 才能;criteria =, accountExample.createCriteria ();   criteria.andAccountNameEqualTo才能(帐号名称);   List<才能;Account>, accountList =, accountService.selectByExample (accountExample);   if 才能;(accountList ==, null  | |, accountList.size (), !=, 1)   ,,,return 零;   其他的才能   ,,,return  accountList.get (0);   }

<>强查询所有列表

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

public  Account  findByAccountName (String 帐号名称),{   AccountExample 才能;AccountExample =, new  AccountExample ();   AccountExample.Criteria 才能;criteria =, accountExample.createCriteria ();   List<才能;Account>, accountList =, accountService.selectByExample (accountExample);   if 才能;(accountList ==, null  | |, accountList.size (), !=, 1)   ,,,return 零;   其他的才能   ,,,return  accountList.get (0);   }

看完上述内容,你们掌握选择方法怎么在Mybatis中使用的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!

选择方法怎么在Mybatis中使用