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. unity探索者之获取设备当前电量

    很多入坑了的小伙伴应该都知道,很多时候做移动端项目都会有显示当前电池电量的需求 对于这个功能,在unity中要做的事并不多,核心方法就一个,自己做一个定时器或者直接使用协程间隔调用该方法就好了 pub ...

  2. 为什么我们需要Logstash,Fluentd等日志摄取器?

    前文传送门:Logging with ElasticSearch, Kibana, ASP.NET Core and Docker 疑问:既然应用能直接向ElasticSearch写日志,为什么我们还 ...

  3. 基于id3算法根据房价数据进行画图预测python

    根据已给的波士顿房价数据,对波斯顿房价进行预测.即,实现给出若干条件(如房间数.社区的低收入阶层的比率和镇上学生与教师数量比例的部分数据),要能说出给出的条件是否能够有效进行预测,如可以做有效预测,则 ...

  4. Vue基础(一)---- 模板语法

    1.基本理解 Vue其实是一个渐进式JavaScript框架,封装好了一些方法,不再需要操作通过操作DOM,在相同的目标下能够更快的编写代码. 声明式渲染→组件系统→客户端路由→集中式状态管理→项目构 ...

  5. 【java学习笔记】LongAdder

    目录 1.背景 2.LongAdder 3.Striped64内部结构 4.LongAdder的add方法解析 5.Striped64的longAccumulate方法解析 6.总结 LongAdde ...

  6. 【原创】探索云计算容器底层之Cgroup

    一.什么是Cgroup,使用场景? 容器本质上是进程,既然是进程就会消耗掉系统资源,比如:CPU.内存.磁盘.网络带宽等,如果不加以限制,容器在某些情况下就会无限制地吃掉宿主机的系统资源,显然这不是我 ...

  7. python练习 - 文本的平均列数+CSV格式清洗与转换

    文本的平均列数 描述 打印输出附件文件的平均列数,计算方法如下:‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬ ...

  8. go语言之接口

    一:接口的基本概念 1 接口声明 接口字面量,接口命名类型,接口声明使用interface关键字. 1)接口字面量类型声明语法如下: interface{ methodSignature1 metho ...

  9. 让“不确定性”变得有“弹性”?基于弹性容器的AI评测实践

    0. 前言 AI的场景丰富多彩,AI的评价方法百花齐放,这对于设计一套更通用的评测框架来说,是一个极大的挑战,需要兼顾不同的协议,不同的模型环境,甚至是不同的操作系统.本文分享了我们在AI评测路上的一 ...

  10. 大数据计算的基石——MapReduce

    MapReduce Google File System提供了大数据存储的方案,这也为后来HDFS提供了理论依据,但是在大数据存储之上的大数据计算则不得不提到MapReduce. 虽然现在通过框架的不 ...