1. SQL语句参数无法获取:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'order_ids' in 'class java.lang.String'

XML映射文件配置:

  <select id="getTransferOrderListByOrderIds" parameterType="String" resultType="HashMap">
select *
from wp_transfer_order
WHERE ORDER_SN IN (${order_ids})
</select>
解决方法: 将parameterType="String"参数改为传一个自定义实体对象或者HashMap来封装这个id参数,就可以在自定义实体对象或者HashMap中找到这个id属性
参考地址:http://www.cnblogs.com/sishang/p/6555176.html 2. SQL语句参数错误:java.lang.RuntimeException: org.mybatis.spring.MyBatisSystemException:
nested exception is org.apache.ibatis.builder.IncompleteElementException:  
not find parameter map com.paycloud.interfaces.dao.AdminUserDao.AdminUserResultMap
(1) XML配置部分:
   <resultMap id="AdminUserResultMap" type="com.paycloud.interfaces.dto.AdminUserDto">
<id column="MUID" jdbcType="INTEGER" property="muId" />
<result column="ROLEID" jdbcType="INTEGER" property="roleId" />
<result column="USERNAME" jdbcType="VARCHAR" property="userName" />
<result column="PASSWORD" jdbcType="VARCHAR" property="passWord" />
<result column="BINDIP" jdbcType="VARCHAR" property="bindIp" />
<result column="LASTIP" jdbcType="VARCHAR" property="lastIp" />
<result column="LASTLOGIN" jdbcType="TIMESTAMP" property="lastLogin" />
<result column="SALTS" jdbcType="CHAR" property="salts" />
<result column="STATUS" jdbcType="INTEGER" property="status" />
<result column="GOOGLECODE" jdbcType="VARCHAR" property="googleCode" />
</resultMap>

  (2) SQL语句部分

  错误案例:

  <!-- 添加用户 -->
<insert id="addAdminUser" parameterMap="AdminUserResultMap" >
insert into sys_admin_user
(ROLEID,USERNAME,PASSWORD,SALTS,STATUS,LASTLOGIN, GOOGLECODE)
values
(#{roleId},#{userName},#{passWord},#{salts},#{status},#{lastLogin}, #{googleCode})
</insert>

  修改后:

  <!-- 添加用户 -->
<insert id="addAdminUser" parameterType="com.paycloud.interfaces.dto.AdminUserDto" >
insert into sys_admin_user
(ROLEID,USERNAME,PASSWORD,SALTS,STATUS,LASTLOGIN, GOOGLECODE)
values
(#{roleId},#{userName},#{passWord},#{salts},#{status},#{lastLogin}, #{googleCode})
</insert>

 

3. 注释搞的鬼:java.lang.RuntimeException: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException:
Could not set parameters for mapping: ParameterMapping{property='pageIndex', mode=IN, javaType=class java.lang.Integer, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}.
Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property.
Cause: java.sql.SQLException: Parameter index out of range (4 > number of parameters, which is 3).
 <!-- 交易统计报表 -->
<select id="getTradeDayStatistics" resultType="Hashmap">
SELECT SUM(t.ORDER_AMOUNT) as order_amount
FROM wp_trade_order t
WHERE t.ORDER_STATUS=1
<if test="tranType != null and tranType != ''"> and t.TRAN_TYPE = #{tranType} </if>
<if test="channelCode != null and channelCode != ''"> and t.CHANNEL_CODE = #{channelCode} </if>
<if test="startTime != null and startTime != ''"> and t.FINISH_TIME >= #{startTime} </if>
<if test="endTime != null and endTime != ''"> and t.FINISH_TIME <= #{endTime} </if>
<if test="minPayMoney != null and minPayMoney != ''"> and t.ORDER_AMOUNT >= #{minPayMoney} </if>
<if test="maxPayMoney != null and maxPayMoney != ''"> and t.ORDER_AMOUNT <= #{maxPayMoney} </if>
/*limit #{pageIndex}, #{pageSize}*/
</select>

 有点粗心,没太在意注释的方式,因为颜色肯定是变灰了,所以出现这个错误。之后把注释去掉就好了。

4.插入时间出现的问题 : Error querying database.  Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String


  <!-- 生成财务流水 -->
<insert id="insertBillings" parameterType="com.paycloud.interfaces.dto.BillingsDto">
INSERT INTO wp_billings
<trim prefix="(" suffix=")" prefixOverrides=",">
<if test="partnerId != null and partnerId != ''">, PARTNER_ID </if>
<if test="tradeTime != null and tradeTime != ''">, TRADE_TIME </if>
</trim>
<trim prefix="VALUES (" suffix=")" prefixOverrides=",">
<if test="partnerId != null and partnerId != ''">, #{partnerId} </if>
<if test="tradeTime != null and tradeTime != '' ">, #{tradeTime} </if>
</trim>
12 </insert>

这是mybatis 3.3.0中对于时间参数进行比较时的一个bug. 如果拿传入的时间类型参数与空字符串''进行对比判断则会引发异常.

所以  and tradeTime != ' ' 删除,只保留非空判断就正常了



												

Mybatis 碰到的一些问题的更多相关文章

  1. 每日一记-mybatis碰到的疑惑:String类型可以传入多个参数吗

    碰到一个觉得很疑惑的问题,Mybatis的parameterType为String类型的时候,能够接收多个参数的吗? 背景 初学Mybatis的时候,看的教程和书籍上都是在说基本的数据类型如:int. ...

  2. SpringBoot整合mybatis碰到的问题

    整合mybatis 1.  导包:在原有的web项目的基础上加上 <!--JDBC连接-->     <dependency>         <groupId>m ...

  3. 初学mybatis和mysql碰到的问题

    今天学习了下使用mybatis操作数据库,期间也是各种问题出现,幸好现在网络发达,网络上很多都可以解决,现在总结一下: Exception in thread "main" org ...

  4. MyBatis通过JDBC生成的执行语句问题

    我们编程的过程中大部分使用了很出色的ORM框架,例如:MyBatis,Hibernate,SpringJDBC,但是这些都离不开数据驱动JDBC的支持.虽然使用起来很方便,但是碰到一些问题确实很棘手, ...

  5. mybatis的一些小总结

    好长时间没用mybatis了,现在项目忽然用mybatis,用的过程中出现了些问题,虽然解决了,不过这花的时间有些长了.总结用的过程中出现的一些问题 1.mapper.xml 之前一直用的自动生成,现 ...

  6. MyBatis的resultMap

    1.大家学习MyBatis时,可能会碰到实体类属性跟数据库字段不同的情况 如:数据库    ------  实体类 stuname  ---->  name 即: 数据库中的stuname字段对 ...

  7. (转)Mybatis高级映射、动态SQL及获得自增主键

    原文:http://www.cnblogs.com/edwinchen/p/4105278.html?utm_source=tuicool&utm_medium=referral 一.动态SQ ...

  8. Spring+SpringMVC+MyBatis+LogBack+C3P0+Maven+Git小结(转)

    摘要 出于兴趣,想要搭建一个自己的小站点,目前正在积极的准备环境,利用Spring+SpringMVC+MyBatis+LogBack+C3P0+Maven+Git,这里总结下最近遇到的一些问题及解决 ...

  9. Mybatis + Mysql 插入数据时中文乱码问题

    近日跟朋友一起建立一个项目,用的是spring+mybatis+mysql. 今天碰到一个mybatis向mysql中插入数据时,中文显示为'???'的问题,拿出来说下. 对于数据库操作中出现的中文乱 ...

随机推荐

  1. python--8、面向对象的深入知识

    面向对象的三大特性 上一篇我们讲的主要内容都符合面向对象的封装特性.那么问题来了?面向对象难道只有封装性么?当然不是,作为一个这么难理解的东西,要是只有封装性都对不起我们死了这么多脑细胞!所以,晴天霹 ...

  2. drupal 8——打补丁(patch)

    druapl 的核心可能会有漏洞,这时就需要我们去打补丁.很多补丁都已经有人写好了,我这里讲的就是如何去打这些已经写好的补丁. 对于这个问题:drupal8 核心有bug导致了两个相同的错误提示的出现 ...

  3. JSP学习笔记 - 内置对象 Request

    1.主要掌握以下5个内置对象及其所属类,必须学会在java docs里根据类名查找相应的方法 request     javax.servlet.http.HttpServletRequest res ...

  4. pandas写入多组数据到excel不同的sheet

    今天朋友问了我个需求,就是如何将多个分析后的结果,也就是多个DataFrame,写入同一个excel工作簿中呢? 之前我只写过放在一个sheet中,但是怎么放在多个sheet中呢?下面我在本地wind ...

  5. Burnside引理和polay计数 poj2409 Let it Bead

    题目描述 "Let it Bead" company is located upstairs at 700 Cannery Row in Monterey, CA. As you ...

  6. What is the difference between rhel 6 and rhel7

    What is the difference between rhel 6 and rhel7 difference rhel 6 RHEL 7 release date 10 NOV 2010 as ...

  7. Netty 长连接服务

    转自:https://www.dozer.cc/2014/12/netty-long-connection.html 推送服务 还记得一年半前,做的一个项目需要用到 Android 推送服务.和 iO ...

  8. 【webpack结合React开发环境配置】React开发环境配置之Webpack结合Babel8.x版本安装的正确姿势(Webpack最新版4.x结合Babel8.x环境配置步骤)

    1. 安装cnpmnpm install -g cnpm --registry=https://registry.npm.taobao.org[使用淘宝镜像]2. 初始化package.json文件c ...

  9. Python学习【第4篇】:Python之文件操作

    文件操作 读取一行 f=open("D:\\1.txt",'rb') print f.readline() f.close() 将文件内容保存在一个list with open(& ...

  10. 理解Mysql prepare预处理语句

    MySQL 5.1对服务器一方的预制语句提供支持.如果您使用合适的客户端编程界面,则这种支持可以发挥在MySQL 4.1中实施的高效客户端/服务器二进制协议的优势.候选界面包括MySQL C API客 ...