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. Vue.js中传值给子部件及触发动作的问题

    最近研究一个用vue.js做的程序并修改增加功能.其中用到传值给子部件等问题. template中有个子部件: <template> ...... <child-form  v-if ...

  2. 使用Postman工具做接口测试(五)——生成随机参数

    引言 我们平时使用最多的接口调试工具就是postman了,比如开发将一个接口给到你,你想看看接口是否正常.最常用的方法就是用postman去调一下.如果通,就写接口测试用例,反之,将开发打一顿吧o(* ...

  3. 蒲公英 &#183; JELLY技术周刊 Vol.18 关于 React 那些设计

    蒲公英 · JELLY技术周刊 Vol.18 自 2011 年,Facebook 第一次在 News Feed 上采用了 React 框架,十年来 React 生态中很多好用的功能和工具在诸多设计思想 ...

  4. 使用 codeblocks 编写C++ udp组播程序遇到的问题

    编译错误 会出现好多undefined reference to'WSAStartup to@8之类的错误,都是undefind开头的 解决方法: Settings -> Compiler se ...

  5. Java成员变量和局部变量的区别

    定义位置不同: 成员变量:类中方法外 分为类变量(static修饰).实例变量(没有使用static修饰) 局部变量:方法内.代码块内 默认值不同: 成员变量:有默认初始化值 局部变量:没有默认初始化 ...

  6. CentOS7上lvm分区调整(resize2fs: Bad magic number in super-block while trying to open ...)

    问题描述:根目录空间占用率100% 首先用传统resize2fs方式调整分区: resize2fs -p /dev/mapper/centos-home 50Gresize2fs 1.42.9 (28 ...

  7. Redis取出中文乱码问题

    直接打开Redis客户端,如果存储了中文的内容,取出时会发生乱码: 解决办法很简单,打开客户端时加上 --raw,这样就可以了: 顺便说一下,-a后面跟的是密码,打码了,各位见谅!

  8. JavaGUI之Swing简单入门示例

    简介 AWT(译:抽象窗口工具包),是Java的平台独立的窗口系统,图形和用户界面器件工具包. Swing 是为了解决 AWT 存在的问题而以 AWT 为基础新开发的包(在使用Swing时也常会用到j ...

  9. promise的常用情况

    因为js是单线程的,所以一旦代码中有报错,就不会执行下面的了,如下333就未打印 console.log(111)throw Error(222)console.log(333) 好像与promise ...

  10. 修改docker0网桥的IP段

    关闭docker进程 systemctl stop docker 修改/etc/docker/daemon.json { "bip": "100.96.2.1/24&qu ...