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. 聊聊MySQL常用的4种主从复制架构

    目录 一主多从复制架构 多级复制架构 双主(Dual Master)复制架构 多源(Multi-Source)复制架构 如何优化主从延迟问题? 复制的4中常见架构有一主多从复制架构.多级复制架构.双主 ...

  2. unity探索者之安卓微信登录,非第三方插件

    版权声明:本文为原创文章,转载请声明http://www.cnblogs.com/unityExplorer/p/7666348.html 之前写了两篇关于微信分享的博客,其实微信登录.分享.支付博主 ...

  3. Springboot + Rabbitmq + WebSocet + vue

    1.pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId& ...

  4. composer安装包的时候触发PHP fatal error,提示允许的内存耗光

    在composer require之前加COMPOSER_MEMORY_LIMIT=-1

  5. superslide滚动插件使用记录-产品滚动-图片滚动

    在用wordpress制作一个企业网站时,用到了这个superslide的滚动插件,用于案例.证书等滚动效果.该插件网站在这里:http://www.superslide2.com/ 我所使用的wor ...

  6. vue组件获取和vue-cli的基本了解

    Vue获取组件的一些方法 this.$refs.xxx 给标签绑定ref属性,获取的是当前DOM对象 给组件绑定ref属性,获取的是组件实例对象 this.$parent 获取当前组件的父组件,为一个 ...

  7. Element UI - DatePicker 自定义日期选择期间

    <el-date-picker v-else v-model="searchForm.data_Selected" type="daterange" un ...

  8. Asp.Net WebAPI的简介及创建

    一.WebAPI简介 ASP.NET Web API 是一种框架,用于轻松构建可以由多种客户端(包括浏览器和移动设备)访问的 HTTP 服务.ASP.NET Web API 是一种用于在 .NET F ...

  9. 学完Python,我决定熬夜整理这篇总结

    目录 了解Python Python基础语法 Python数据结构 数值 字符串 列表 元组 字典 集合 Python控制流 if 判断语句 for 循环语句 while 循环语句 break 和 c ...

  10. pybind11: C++ 工程如何提供 Python 接口

    C/C++ 工程提供 Python 接口,有利于融合进 Python 的生态.现在 Python 在应用层,有其得天独厚的优势.尤其因为人工智能和大数据的推波助澜, Python 现在以及未来,将长期 ...