Mybatis中Mapper内置方法细解

来源:互联网 发布:oracle删除重复数据 编辑:程序博客网 时间:2024/06/17 22:46

MVC的设计模式解释:

model层就是实体类,对应数据库的表。controller层是Servlet,主要是负责业务模块流程的控制,调用service接口的方法,在struts2就是Action。Service层主要做逻辑判断,Dao层是数据访问层,与数据库进行对接。至于Mapper是mybtis框架的映射用到,mapper映射文件在dao层用。

下面是介绍一下Mapper的内置方法:

1、countByExample ===>根据条件查询数量

 

 2、deleteByExample ===>根据条件删除多条

 

3、deleteByPrimaryKey===>根据条件删除单条

 

4、insert===>插入数据

 

5、insertSelective===>插入数据

 

6、selectByExample===>根据条件查询数据

 

7、selectByPrimaryKey===>根据主键查询数据

 

8、updateByExampleSelective===>按条件更新值不为null的字段

 

9、updateByExampleSelective===>按条件更新

 

10、updateByPrimaryKeySelective===>按条件更新

 

11、updateByPrimaryKey===>按主键更新

原创粉丝点击