【20210611】Mybatis中Example使用说明
发布时间:2023-02-02 00:03:01 来源:文档文库
小
中
大
字号:
MybatisExample使用方法一、mapper接口中的方法解析mapper接口中的函数及方法>>>>intcountByExample(UserExampleexamplethorwsSQLException按条件计数>>>>intdeleteByPrimaryKey(IntegeridthorwsSQLException按主键删除>>>>intdeleteByExample(UserExampleexamplethorwsSQLException按条件查询>>>>String/Integerinsert(UserrecordthorwsSQLException插入数据(返回值为ID)>>>>UserselectByPrimaryKey(IntegeridthorwsSQLException按主键查询>>>>ListselectByExample(UserExampleexamplethorwsSQLException按条件查询>>>>ListselectByExampleWithBLOGs(UserExampleexamplethorwsSQLException>>>>按条件查询(包括BLOB字段)。只有当数据表中的字段类型有为二进制的才会产生。>>>>intupdateByPrimaryKey(UserrecordthorwsSQLException按主键更新>>>>intupdateByPrimaryKeySelective(UserrecordthorwsSQLException>>>>按主键更新值不为null的字段>>>>intupdateByExample(Userrecord,UserExampleexamplethorwsSQLException按条
>>>>件更新>>>>intupdateByExampleSelective(Userrecord,UserExampleexamplethorwsSQLException>>>>按条件更新值不为null的字段二.example实例解析mybatis的逆向工程中会生成实例及实例对应的example,example用于添加条件,相当where后面的部分xxxExampleexample=newxxxExample(;>>>>Criteriacriteria=newExample(.createCriteria(;example.setOrderByClause(“字段名ASC”;添加升序排列条件,DESC为降序>>>>example.setDistinct(false去除重复,boolean型,true为选择不重复的记录。>>>>criteria.andXxxIsNull