zoukankan      html  css  js  c++  java
  • Mybatis selectKey标签的keyProperty属性报错,关键字间隔不能有空格

    源代码片段:

    1 <insert id="addAdminAction" parameterType="x.x.x.RoleVo">
    2     <selectKey keyProperty="idRole, createdDate" resultType="x.x.x.RoleVo" order="BEFORE">
    3        select getid() idRole, to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') createdDate from dual 
    4     </selectKey>
    5     <!-- insert sql--> 
    6 </insert>

    报错内容:

     1 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' createdDate' in 'class x.x.x.RoleVo' 

    原因:当keyProperty有多个目标列时,列关键字之间用逗号","分隔,并且不应有多余空格(即keyProperty="idRole, createdDate"间不应该有空格)。

    正确代码片段:

    1 <insert id="addAdminAction" parameterType="x.x.x.RoleVo">
    2     <selectKey keyProperty="idRole,createdDate" resultType="x.x.x.RoleVo" order="BEFORE">
    3        select getid() idRole, to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') createdDate from dual 
    4     </selectKey>
    5     <!-- insert sql--> 
    6 </insert>

    一个空格引起的错误,个人觉得还是挺有意思的

  • 相关阅读:
    28家知名IT公司名称的由来
    URI和URL及URN的区别
    URI和URL及URN的区别
    URI和URL及URN的区别
    程序员如何保护自己的颈椎
    程序员如何保护自己的颈椎
    程序员如何保护自己的颈椎
    ACM2050
    应对百万访问量的epoll模式
    敏捷开发方法(一) Scrum
  • 原文地址:https://www.cnblogs.com/LinBug/p/7544486.html
Copyright © 2011-2022 走看看