输入和输出映射
通过parameterType完成输入映射,通过resultType和resultMap完成输出映射。 1.1parameterType传递pojo包装对象
可以定义pojo包装类型扩展mapper接口输入参数的内容。 需求:
自定义查询条件查询用户信息,需要向statement输入查询条件,查询条件可以有user信息、商品信息。。。。 1.1.1包装类型

1.1.1mapper.xml

1.1.1Mapper.java接口

测试

异常
如果parameterType中指定属性错误,异常,找不到getter方法: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userCusto' in 'class cn.itcast.mybatis.po.UserQueryVo'
### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userCusto' in 'class cn.itcast.mybatis.po.UserQueryVo' 注意:如果将来和spring整合后,不是通过调用getter方法来获取属性值,通过反射强读取pojo的属性值。
1.1resultType
指定输出结果的类型(pojo、简单类型、hashmap..),将sql查询结果映射为java对象 。 1.1.1返回简单类型
mapper.xml

mapper.java

注意:
如果查询记录结果集为一条记录且一列再使用返回简单类型。

mybatis12 Usermapper.xml的更多相关文章

  1. 在userMapper.xml文件中模糊查询的常用的3种方法

    在userMapper.xml文件中新建映射sql的标签 <!-- ******************** 模糊查询的常用的3种方式:********************* --> ...

  2. Error building SqlSession. ### The error may exist in dao/UserMapper.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration(2 字节的 UTF-8 序列的字节 2 无效。)

    关于在学习Mybatis框架时运行报错 Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error building ...

  3. IDEA报错:Could not find resource com/liwen/bean/userMapper.xml

    主要原因设idea无法识别src路径下的xml文件,要把xml文件建立在resources文件下

  4. mybatis入门基础(三)----SqlMapConfig.xml全局配置文件解析

    一:SqlMapConfig.xml配置文件的内容和配置顺序如下 properties(属性) settings(全局配置参数) typeAiases(类型别名) typeHandlers(类型处理器 ...

  5. Mybatis学习错误之:重复加载mapper.xml

    学习mybatis的时候,突然遇到测试出错.测试mapper代理失败,现在钻研少了,不喜欢看未知的错误了,立即改正.错误打印说mapper.xml已经注册,仔细查看SQLMapConfig.xml发现 ...

  6. mybatis-config.xml简单笔记

    mybatis-config.xml简单笔记 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ...

  7. 13Mybatis_SqlMapConfig.xml专题讲解

    Mybatis的SqlMapConfig.xml中以下的标签: properties(属性) settings(全局配置参数) typeAliases(类型别名) typeHandlers(类型处理器 ...

  8. 五 mybatis的SqlMapConfig.xml详解

    SqlMapConfig.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE conf ...

  9. mybatis系列-05-SqlMapConfig.xml详解

    mybatis的全局配置文件SqlMapConfig.xml,配置内容如下: properties(属性) settings(全局配置参数) typeAliases(类型别名) typeHandler ...

随机推荐

  1. skiplist 跳表(1)

    最近学习中遇到一种新的数据结构,很实用,搬过来学习. 原文地址:skiplist 跳表   为什么选择跳表 目前经常使用的平衡数据结构有:B树,红黑树,AVL树,Splay Tree, Treep等. ...

  2. 程序异常捕获库 - CrashRpt

    CrashRpt.dll用来在应用程序出现异常crash时,捕获到错误. 并收集出错信息: MiniDump文件.硬件信息.系统信息.出错信息.进程信息.服务信息.驱动信息.启动信息.软件列表.端口信 ...

  3. leetcode面试准备:Valid Anagram

    leetcode面试准备:Valid Anagram 1 题目 Given two strings s and t, write a function to determine if t is an ...

  4. JavaScript字符串的操作

    <script> var s=new String(); var s="Hello World"; alert(s.toLowerCase(s));//转小写 aler ...

  5. 一起啃PRML - 1.2 Probability Theory 概率论

    一起啃PRML - 1.2 Probability Theory @copyright 转载请注明出处 http://www.cnblogs.com/chxer/ A key concept in t ...

  6. SharePoint2010沙盒解决方案基础开发——关于TreeView树形控件读取列表数据(树形导航)的webpart开发及问题

    转:http://blog.csdn.net/miragesky2049/article/details/7204882 SharePoint2010沙盒解决方案基础开发--关于TreeView树形控 ...

  7. SharePoint 2010顶部链接导航栏的详细操作

    转:http://www.360sps.com/Item/UseTopLink.aspx 在SharePoint 2010环境的页面中,导航链接总体上可以分为两类,一类是显示在左侧的快速启动栏,另一类 ...

  8. GeoTools应用-DATA

    转自:http://blog.csdn.net/cdl2008sky/article/details/7266785 一.Geotools The Open Source Java GIS Toolk ...

  9. How to make project not set to be build

    1.BUILD->Configuration Management... 2. When you guys add new projects to the kiosk solution plea ...

  10. Axure RP 8.0 中继器初体验

    为了解决增删等复杂交互的问题,中继器是个不错的选择. 拖拽出一个默认的中继器 中继器的数据集感觉就像是数据库一样,在右边检视窗口中可以看到中继器的默认数据集,可以理解成一张二维表.默认有1列,现成的3 ...