Mybatis的Example經常使用函數和Mapper經常使用接口

1.Example經常使用函數
        mybatis的逆向工程中會生成實例以及實例對應的example,example用於添加條件,至關於where後面的部分。
        Example    example    =new    Example(實體類.class);
        example.createCriteria().添加條件
        經常使用函數以下:
        (1)example.setDistinct(false):去除重複,boolean類型,true表示選擇不重複的記錄。
        (2)example.setOrderByClause(「字段名  ASC 」):添加升序排列條件,DESC爲降序。
        (3)example.createCriteria().andEqualTo("xxx字段",value):添加xxx字段等於value的條件。
        (4)example.createCriteria().andNotEqualTo("xxx字段",value):添加xxx字段不等於value的條件。
        (5)example.createCriteria().andCreaterThan("xxx字段",value):添加xxx字段大於value的條件。
        (6)example.createCriteria().andLessThan("xxx字段",value):添加xxx字段名小於value的條件。
        (7)example.createCriteria().andLessThanOrEqualTo("xxx字段",value):添加字段名小於等於value的條件。
        (8)example.createCriteria().andIn(List<?>):添加字段值在List<?>中的條件。
        (9)example.createCriteria().andNotIn(List<?>):添加字段值不在List<?>中的條件。
        (10)example.createCriteria().andLike("xxx字段","%"+value+"%"):添加xxx字段值爲value的模糊查詢。
        (11)example.createCriteria().andNotLike("xxx字段","%"+value+"%"):添加xxx字段值不爲value的模糊查詢。
        (12)example.createCriteria().andBetween("value1,value2):添加xxx字段值在value1和value2之間的條件。
        (13)example.createCriteria().andNotBetween("value1,value2):添加xxx字段值不在value1和value2之間的條件。
        (14)example.createCriteria().andIsNull("xxx字段",value):添加xxx字段值爲null的條件。
        (15)example.createCriteria().andIsNotNull("xxx字段",value):添加xxx字段值不爲null的條件。
2.Mapper經常使用接口
        (1)int  countByExample(example):按條件計數。
        (2)int  updateByExample(實體類,example):按條件更新。
        (3)int  updateByExampleSelective(實體類,example):按條件更新部位null的字段。
        (4)int  updateByPrimaryKey(實體類):按主鍵更新。
        (5)int  countByPrimaryKeySelective(實體類):按主鍵更新不爲null的字段。
        (6)int  deleteByPrimaryKey(id):按主鍵刪除。
        (7)int  deleteByExample(example):按條件刪除。
        (8)String/Integer  insert(實體類):插入數據(返回值爲id)。
        (9)返回值類型  selectByPrimaryKey(id):按主鍵查詢。
        (10)返回值類型  selectByExample(example):按條件查詢。
        (11)int  selectByExampleWithBLOGS(example):按條件查詢(包括BLOB)字段。只有當數據表中的字段類型有爲二進制時纔會產生。mybatis

相關文章
相關標籤/搜索