日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

MyBatis整合Spring的实现(16)

發布時間:2023/12/16 javascript 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MyBatis整合Spring的实现(16) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。