2019独角兽企业重金招聘Python工程师标准>>>

本章中分析update元素的解析。

1 配置文件

<update id="updateByPrimaryKeySelective" parameterType="cn.vansky.schedule.time.menu.bo.Menu"><!--WARNING - @mbggeneratedThis element is automatically generated by MyBatis Generator, do not modify.This element was generated on Fri Aug 14 16:08:36 CST 2015.-->update tb_menu<set><if test="menuName != null">menu_name = #{menuName,jdbcType=VARCHAR},</if><if test="menuRemark != null">menu_remark = #{menuRemark,jdbcType=VARCHAR},</if><if test="menuParentId != null">menu_parent_id = #{menuParentId,jdbcType=INTEGER},</if><if test="menuUrl != null">menu_url = #{menuUrl,jdbcType=VARCHAR},</if><if test="isShow != null">is_show = #{isShow,jdbcType=TINYINT},</if><if test="isDelete != null">is_delete = #{isDelete,jdbcType=TINYINT},</if><if test="operationUserName != null">operation_user_name = #{operationUserName,jdbcType=VARCHAR},</if><if test="operationTime != null">operation_time = #{operationTime,jdbcType=TIMESTAMP},</if></set>where Id = #{id,jdbcType=INTEGER}
</update>

2 方法parseStatementNode

public void parseStatementNode() {// updateByPrimaryKeySelectiveString id = context.getStringAttribute("id");// nullString databaseId = context.getStringAttribute("databaseId");// 第一次检查这里是不通过的,直接跳过if (!databaseIdMatchesCurrent(id, databaseId, this.requiredDatabaseId)) return;// null Integer fetchSize = context.getIntAttribute("fetchSize");// nullInteger timeout = context.getIntAttribute("timeout");// nullString parameterMap = context.getStringAttribute("parameterMap");// cn.vansky.schedule.time.menu.bo.MenuString parameterType = context.getStringAttribute("parameterType");// class cn.vansky.schedule.time.menu.bo.MenuClass<?> parameterTypeClass = resolveClass(parameterType);// nullString resultMap = context.getStringAttribute("resultMap");// nullString resultType = context.getStringAttribute("resultType");// nullString lang = context.getStringAttribute("lang");// 获取默认的处理对象// org.apache.ibatis.scripting.xmltags.XMLLanguageDriverLanguageDriver langDriver = getLanguageDriver(lang);// nullClass<?> resultTypeClass = resolveClass(resultType);// nullString resultSetType = context.getStringAttribute("resultSetType");// PREPAREDStatementType statementType = StatementType.valueOf(context.getStringAttribute("statementType", StatementType.PREPARED.toString()));// nullResultSetType resultSetTypeEnum = resolveResultSetType(resultSetType);// updateString nodeName = context.getNode().getNodeName();// UPDATESqlCommandType sqlCommandType = SqlCommandType.valueOf(nodeName.toUpperCase(Locale.ENGLISH));// falseboolean isSelect = sqlCommandType == SqlCommandType.SELECT;// trueboolean flushCache = context.getBooleanAttribute("flushCache", !isSelect);// falseboolean useCache = context.getBooleanAttribute("useCache", isSelect);// falseboolean resultOrdered = context.getBooleanAttribute("resultOrdered", false);// Include Fragments before parsingXMLIncludeTransformer includeParser = new XMLIncludeTransformer(configuration, builderAssistant);// 解析<include refid="Base_Column_List" />includeParser.applyIncludes(context.getNode());// Parse selectKey after includes and remove them.processSelectKeyNodes(id, parameterTypeClass, langDriver);// 这里很明显也是动态SQL// org.apache.ibatis.scripting.xmltags.DynamicSqlSourceSqlSource sqlSource = langDriver.createSqlSource(configuration, context, parameterTypeClass);// nullString resultSets = context.getStringAttribute("resultSets");// nullString keyProperty = context.getStringAttribute("keyProperty");// nullString keyColumn = context.getStringAttribute("keyColumn");// org.apache.ibatis.executor.keygen.NoKeyGeneratorKeyGenerator keyGenerator;// updateByPrimaryKeySelective!selectKeyString keyStatementId = id + SelectKeyGenerator.SELECT_KEY_SUFFIX;// cn.vansky.schedule.time.menu.dao.MenuMapper.updateByPrimaryKeySelective!selectKeykeyStatementId = builderAssistant.applyCurrentNamespace(keyStatementId, true);if (configuration.hasKeyGenerator(keyStatementId)) {keyGenerator = configuration.getKeyGenerator(keyStatementId);} else {keyGenerator = context.getBooleanAttribute("useGeneratedKeys",configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType))? new Jdbc3KeyGenerator() : new NoKeyGenerator();}builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,resultSetTypeEnum, flushCache, useCache, resultOrdered, keyGenerator, keyProperty, keyColumn, databaseId, langDriver, resultSets);}

updateByPrimaryKeySelective最终的MappedStatement

下面就来看动态SqlSource的属性。

转载于:https://my.oschina.net/u/1269959/blog/523851

MyBatis整合Spring的实现(16)相关推荐

  1. MyBatis整合Spring的实现(2)

    2019独角兽企业重金招聘Python工程师标准>>> 分析 MyBatis整合Spring的实现(1)中代码实现的4.1可以知道,XMLConfigBuilder类读取MyBati ...

  2. MyBatis整合Spring原理分析

    目录 MyBatis整合Spring原理分析 MapperScan的秘密 简单总结 假如不结合Spring框架,我们使用MyBatis时的一个典型使用方式如下: public class UserDa ...

  3. (转)MyBatis框架的学习(六)——MyBatis整合Spring

    http://blog.csdn.net/yerenyuan_pku/article/details/71904315 本文将手把手教你如何使用MyBatis整合Spring,这儿,我本人使用的MyB ...

  4. Mybatis——Mybatis整合Spring详解

    mybatis-spring官网 1. MyBatis整合Spring实现 我们首先实现MyBatis和Spring的整合操作. 1.1 添加相关的依赖 这些是整合的依赖,不包括其他分页插件等依赖. ...

  5. 【Mybatis+spring整合源码探秘】--- mybatis整合spring事务原理

    文章目录 1 mybatis整合spring事务原理 1 mybatis整合spring事务原理 本篇文章不再对源码进行具体的解读了,仅仅做了下面一张图: 该图整理了spring+mybatis整合后 ...

  6. Spring学习笔记:Spring整合Mybatis(mybatis-spring.jar)(二:mybatis整合spring)

    http://blog.csdn.net/qq598535550/article/details/51703190 二.Spring整合mybatis其实是在mybatis的基础上实现Spring框架 ...

  7. MyBatis(五)MyBatis整合Spring原理分析

    前面梳理了下MyBatis在单独使用时的工作流程和关键源码,现在看看MyBatis在和Spring整合的时候是怎么工作的 也先从使用开始 Spring整合MyBatis 1.引入依赖,除了MyBati ...

  8. Mybatis整合spring

    整合思路 1.SqlSessionFactory对象应该放到spring容器中作为单例存在. 2.传统dao的开发方式中,应该从spring容器中获得sqlsession对象. 3.Mapper代理形 ...

  9. mybatis 整合spring之mapperLocations配置的问题

    今天尝试spring整合mybatis时遇到这么一个问题,就是在配置sqlSessionFactory时是否要配置mapperLocations的问题. <bean id="sessi ...

  10. mybatis整合spring下的的各种配置文件

    1.applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans ...

最新文章

  1. KubeEdge — Overview
  2. Android开发--Notification和PendingIntent
  3. 极简数据分析实操指南(下)
  4. static void SetSysClockTo72(void)的一些理解
  5. 数据库同步热备方案(云南某金属企业)
  6. Index of sql server
  7. Vue指令篇_v-model_数据双向绑定
  8. 阿里云Redis混合存储典型场景:如何轻松搭建视频直播间系统
  9. 使用DistroTweaks复制您的自定义Linux设置
  10. angular tslint 自动修正
  11. 记录一次cordova升级react native安装失败版本过低的趟坑之旅
  12. 手机无启动抓拍的想法
  13. ITIL学习(四) 服务、IT服务、服务台管理、IT服务管理
  14. 分布式session解决方案
  15. excel单元格内容拆分_Excel分列解决不了的问题,VBA轻松搞定之拆分单元格
  16. usb热插拔多次之后无法识别
  17. python uiautomator2控制手机点击_uiautomator2 python远程操作Android
  18. Vue进阶(幺贰叁):v-for 实现一行展示 n 个元素
  19. ARM Mbed在线IDE编程意法半导体(ST)开发板
  20. 微软亚洲研究院 可视化_如何为亚洲市场本地化手机游戏

热门文章

  1. [工具分享]阿里云语音合成方言和外语Windows版本
  2. 如何将离线DAT卫星影像解压为瓦片?
  3. 成功,侥幸,以小博大?永远离不开的墨菲定律
  4. 语音可懂度评估(一)——基于清晰度指数的方法
  5. java工程源码看不懂_目前从事java开发工作,看不懂源码应该怎么做?
  6. matlab 压缩采样恢复,MATLAB|测试信号压缩采样
  7. 在linux下比较好用的chm阅读器和飞信软件
  8. 电脑重装系统详细教程(以安装win10为例)
  9. 2022-2027年中国智能服务机器人行业发展监测及投资战略研究报告
  10. 三层交换机的工作原理