【20210611】Mybatis中Example使用说明

发布时间:2023-02-02 00:03:01

MybatisExample使用方法一、mapper接口中的方法解析mapper接口中的函数及方法intcountByExample(UserExampleexamplethorwsSQLException按条件计数intdeleteByPrimaryKey(IntegeridthorwsSQLException按主键删除intdeleteByExample(UserExampleexamplethorwsSQLException按条件查询String/Integerinsert(UserrecordthorwsSQLException插入数据(返回值为IDUserselectByPrimaryKey(IntegeridthorwsSQLException按主键查询ListselectByExample(UserExampleexamplethorwsSQLException按条件查询ListselectByExampleWithBLOGs(UserExampleexamplethorwsSQLException按条件查询(包括BLOB字段)。只有当数据表中的字段类型有为二进制的才会产生。intupdateByPrimaryKey(UserrecordthorwsSQLException按主键更新intupdateByPrimaryKeySelective(UserrecordthorwsSQLException按主键更新值不null的字段intupdateByExample(Userrecord,UserExampleexamplethorwsSQLException按条
件更新intupdateByExampleSelective(Userrecord,UserExampleexamplethorwsSQLException按条件更新值不为null的字段.example实例解析mybatis的逆向工程中会生成实例及实例对应的exampleexample用于添加条件,相当where后面的部分xxxExampleexample=newxxxExample(;Criteriacriteria=newExample(.createCriteria(;example.setOrderByClause(“字段名ASC;添加升序排列条件,DESC为降序example.setDistinct(false去除重复,boolean型,true为选择不重复的记录。criteria.andXxxIsNull添加字段xxxnull的条件criteria.andXxxIsNotNull添加字段xxx不为null的条件criteria.andXxxEqualTo(value添加xxx字段等于value条件criteria.andXxxNotEqualTo(value添加xxx字段不等于value条件criteria.andXxxGreaterThan(value添加xxx字段大于value条件

【20210611】Mybatis中Example使用说明

相关推荐