1.查询

//    查询
@Select("select id, name, type, numbers, cancelled, completed, percentage from customer_list")
List<CustomerList> selectCustomerListAll();   //多表联查
  //所有的关联实体类必须引入此注解 @JsonIgnoreProperties(value = {"handler","hibernateLazyInitializer","fieldHandler"})
  @Select("select id, user_name, remarks, service_id, from jurisdiction_role ")
  @Results(id="resultMap", value = {
@Result(column = "id" , property = "id" ,id=true),
@Result(column = "user_name" ,property = "user_name"),
@Result(column = "remarks",property = "remarks"),
@Result(property = "service_id",column = "service_id" , //com.cn.test.mapper.JurisdictionServiceMapper.selectJurisdictionServiceOneId 引入的此mapper必须实现此查询方法
                many = @Many(select = "com.cn.test.mapper.JurisdictionServiceMapper.selectJurisdictionServiceOneId",
fetchType = FetchType.LAZY)),
  })
  List<JurisdictionRole> selectJurisdictionRoleAll();   //com.cn.test.mapper.JurisdictionServiceMapper.selectJurisdictionServiceOneId
  @Select("select id, name, imports, repair_statistics, annual_completion_rate, work_order_statistics, app_amount, app_times, usage_statistics, " +
"satisfaction_survey, device_status from jurisdiction_service where id = #{id}")
  JurisdictionService selectJurisdictionServiceOneId(Integer id);

2.修改
//    修改
@Update("<script> update customer_list set <if test = 'name != null'> name = #{name} ,</if>" +
"<if test = 'type != null'> type = #{type} ,</if>" +
"<if test = 'numbers != null'> numbers = #{numbers} ,</if>" +
"<if test = 'cancelled != null'> cancelled = #{cancelled} ,</if>" +
"<if test = 'completed != null'> completed = #{completed} ,</if>" +
"<if test = 'percentage != null'> percentage = #{percentage} ,</if>" +
"id = #{id} where id = #{id}</script>")
int updateCustomerListOneId(CustomerList customerList); 3.添加
  @Insert("insert into jurisdiction_role (user_name, remarks, state)" +
"values (#{user_name}, #{remarks}, #{state})")
  int insertIntoJurisdictionRoleIdOne(JurisdictionRole jurisdictionRole);
4.删除
  @Delete("delete from locks where id = #{id}")
  int deleteLocksOneId(Integer id);
 
注:以上内容仅供个人学习记录使用,如有问题,请慎用!

Mybatis 注解形式的更多相关文章

  1. springboot之mybatis注解形式

    springboot整合mybatis对数据库进行访问,本实例采用注解的方式,如下: pom.xml文件 <parent> <groupId>org.springframewo ...

  2. mybatis 注解形式设置批量新增、批量更新数据

    1. 批量更新: @Update({"<script>" + "<foreach collection=\"smsConfigTemplate ...

  3. 使用mybatis调用存储过程(注解形式和配置文件形式)

    最近在看资料中涉及到mybatis,突然想到mysql中的视图.存储过程.函数.现将在使用mybatis调用mysql的存储过程使用总结下: 使用的环境:mybatis3.4.6,mysql 5.6, ...

  4. mybatis基于注解形式的多数据源

    最近在做一个系统管理项目,需要使用到多数据源,尝试了注解形式和xml形式的多数据源配置,以下是基于注解形式的Mybatis多数据源配置. 1.application.yml 配置文件 database ...

  5. SSM框架——以注解形式实现事务管理

    上一篇博文<SSM三大框架整合详细教程>详细说了如何整合Spring.SpringMVC和MyBatis这三大框架.但是没有说到如何配置mybatis的事务管理,在编写业务的过程中,会需要 ...

  6. mybatis注解详解

    首 先当然得下载mybatis-3.0.5.jar和mybatis-spring-1.0.1.jar两个JAR包,并放在WEB-INF的lib目录下 (如果你使用maven,则jar会根据你的pom配 ...

  7. mybatis入门篇:Mybatis注解方式的基本用法

    @Select 1.mybatis-config.xml <?xml version="1.0" encoding="UTF-8" ?> <! ...

  8. MyBatis注解Annotation介绍及Demo

     MyBatis注解Annotation介绍及Demo 2014-04-21 17:09:55 标签:Mybatis Annotation 注解 ResultMap SqlBuilder 原创作品,允 ...

  9. mybatis注解实现CURD

    我们来看下面这段代码: /** * The user Mapper interface. * * @author Wangzun * * @version 1.0 * * */ @CacheNames ...

随机推荐

  1. 前端vue2-org-tree实现精美组织架构图

    最近遇到开发组织架构的需求,与以往开发的组织架构不同,不光要展示人名,还要显示职务(或者子公司名称).对应的头像等,并且要考虑,如果用户未上传头像,需使用默认头像(男.女.中性),(⊙o⊙)…要尊重尊 ...

  2. Python基础入门知识点——深浅拷贝

    深浅拷贝 对象引用.浅拷贝.深拷贝(拓展.难点.重点) Python中,对象的赋值,拷贝(深/浅拷贝)之间是有差异的,如果使用的时候不注意,就可能产生意外的结果 其实这个是由于共享内存导致的结果 拷贝 ...

  3. python re之search/match差别

    search → find something anywhere in the string and return a match object. match → find something at ...

  4. SpringBoot整合Redis并完成工具类

    SpringBoot整合Redis的资料很多,但是我只需要整合完成后,可以操作Redis就可以了,所以不需要配合缓存相关的注解使用(如@Cacheable),而且我的系统框架用的日志是log4j,不是 ...

  5. 循序渐进VUE+Element 前端应用开发(19)--- 后端查询接口和Vue前端的整合

    循序渐进VUE+Element 前端应用开发的系列文章中,前面介绍了系统各个功能的处理实现,本篇随笔从一个主线上介绍前后端开发的整合,让我们从ABP框架后端的查询接口的处理,前端API接口调用的封装, ...

  6. 调试 Ingress Nginx

    由于 Ingress Nginx 是最受欢迎的 Ingress 控制器,因此接下来我们将介绍一些有关调试 ingress-nginx 的技巧. 调试 Ingress Nginx Ingress-ngi ...

  7. Vue | 自定义指令和动态路由实现权限控制

    功能概述: 根据后端返回接口,实现路由动态显示 实现按钮(HTML元素)级别权限控制 涉及知识点: 路由守卫 Vuex使用 Vue自定义指令 导航守卫 前端工程采用Github开源项目Vue-elem ...

  8. mysql 8.0.19 win10快速安装教程

    本文教程为大家分享了mysql 8.0.19安装教程,供大家参考,具体内容如下 1.下载.zip安装文件 2.根目录存放my.ini,文件路径用“/”分割,例如: [mysqld] port=3306 ...

  9. 好看的css渐变颜色大全网址

    60个渐变颜色 https://webkul.github.io/coolhue/ 60个非常有用的CSS代码片段 https://baijiahao.baidu.com/s?id=160278735 ...

  10. Cacti1.2.14最新版安装和配置(详细版)

    Cacti的起源与发展现状 故事要从2001年的某一天说起.一个叫Ian Berry的中学生还在学习如何使用PHP和MySQL进行编程及功能的实现,那时候他业余时间为一个名不见经传的互联网运营商开发项 ...