已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Ibatis2 到 mybatis3 的转变连接数据库配置文件New DTDsNew sqlMapConfig.xml DTD: New sqlMap (*.map.xml) DTD: Configuration Root configuration tag is now SettingsWithin the root configuration tag: is now: and can be removed, since the use of namespaces has become mandatory. must be moved out of the element to . and is now: is now: Mapping The root element is now The attribute parameterClass should be changed to parameterType The attribute resultClass should be changed to resultType The attribute class should be changed to type the columnIndex attribute does not exist anymore for the tag The groupBy attribute has been eliminated. Here is an example of groupBy from a 2.x sqlMap: New: Nested resultMapsThese should now be specified using the tag. .is now: .Although this tag is deprecated, it can be used as in iBatis 2. However for versions up to 3.0.3 there is a bug when using type=map and not specifying javaType for a parameter. This will result in There is no getter for property named . in interface java.util.Map This should be solved in MyBatis 3.0.4. For versions 3.0.3 and earlier the workaround is to explicitly specify javaType. Inline parameters#value#is now: #valuejdbcType changesjdbcType=ORACLECURSORis now: jdbcType=CURSORand jdbcType=NUMBERis now: jdbcType=NUMERICStored procedures the tag doesnt exist anymore. Use , or . ? = call pkgExample.getValues(p_id = ?) is now: ? = call pkgExample.getValues(p_id = ?)If youre calling an insert procedure that returns a value, you can use instead of , but make sure to specify useCache=false and flushCache=true. Youll also have to force a commit. for stored procedures that return a cursor, there is a bug (see issue 30) when using nested result maps (i.e. the output parameters resultMap contains an tag with the resultMap attribute). As long as the issue is not fixed, you have to specify the resultMap of the output parameter on the statement itself as well, or the nested resultMap will not be populated. Caching is now: Note: you can omit eviction=LRU since it is the default. the tag is replaced by the flushCache attribute for the statements and the cache will be used by all select statements by default. Dynamic SQLThe most common dynamic SQL in my project is isNotNull. Here is an example replacement regex: Pattern: Replacement: 配置文件示例SqlMapConfig Mapper SELECT MAX(SYCK_SMS_LIST_ID) FROM T_SYCK_SMS_LIST #startSmsListId and SMS.SYCK_SMS_LIST_ID 高级映射一对一映射 封装时引用别的resultMap,这里你也可以直接在这里写,如下: 建议采用引用,因为那样可以重复利用一对多映射集合的封装是一样的注意:这里的集合映射只能映射实现或者间接实现collection接口的集合类,不能使用Map; 属性对象声明的集合要和这里存放的保持一致动态Sql书写 Mybatis3支持OGNL表达式 在sqlMap的xml文件中可以直接使用 像 ORG_NAME like %|#orgName|%除了if ,mybatis还支持 choose,when , otherwise trim,where,set,foreach 等注意 foreach 只支持 list array文本替换mybatis3的用户指南里关于字符串替换的解释是:字符串替换 默认情况下,使用#格式的语法会导致 MyBatis 创建预处理语句属性并以它为背景设置安全的值(比如?)。这样做很安全,很迅速也是首选做法,有时你只是想直接在 SQL 语句中插入一个不改变的字符串。比如,像 ORDER BY,你可以这样来使用: ORDER BY $columnName 这里 MyBatis 不会修改或转义字符串。 重要:接受从用户输出的内
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025四川大学华西第二医院招聘外聘门诊医师历年真题汇编带答案解析
- 2026年设备监理师之设备工程监理基础及相关知识考试题库200道附答案【b卷】
- 中共南部县委组织部关于2025年南部县党政机关公开考调工作人员(16人)备考题库带答案解析
- 2026奇瑞汽车博士校园招聘历年真题汇编附答案解析
- 2025下半年四川宜宾市高县事业单位考核招聘37人备考题库附答案解析
- 2025内蒙古呼和浩特经开区物业管理集团有限公司招聘工作人员4人模拟试卷附答案解析
- 2026陕西省面向重庆大学招录选调生历年真题汇编带答案解析
- 2025中铁上海设计院集团有限公司招聘8人笔试模拟试卷带答案解析
- 2025大兴区第十批公益性岗位招聘3人参考题库带答案解析
- 2025河南洛阳理思实验学校高中部招聘骨干教师(储备)历年真题库附答案解析
- CJ/T 355-2010小型生活污水处理成套设备
- 护理核心制度试题及答案问卷星n1
- 管培生合同协议书
- 基于纳米模型的CNTFET器件:机理剖析与模型构建研究
- 新疆开放大学2025年春《国家安全教育》形考作业1-4终考作业答案
- 2025万家寨水务控股集团所属企业校园招聘82人笔试参考题库附带答案详解
- 康复医院双向转诊流程及案例分析
- 风机安装安全管理制度
- 2022桶装饮用水 PC 罐清洗消毒卫生规范
- 湖南省长沙市雅礼教育集团2024-2025学年九年级3月月考道德与法治试题(原卷版+解析版)
- 病理科年终总结
评论
0/150
提交评论