java.sql.SQLException:列索引无效(从iBATIS迁移到MyBatis时)

时间:2017-07-08 09:59:43

标签: migration mybatis ibatis wildfly-10

将应用程序从iBATIS迁移到MyBatis时面临此问题

  

org.mybatis.spring.MyBatisSystemException:嵌套异常是org.apache.ibatis.type.TypeException:无法设置映射参数:ParameterMapping {property ='userDefRole',mode = null,javaType = class java.lang。 String,jdbcType = VARCHAR,numericScale = null,resultMapId ='null',jdbcTypeName ='null',expression ='null'}。原因:org.apache.ibatis.type.TypeException:使用JdbcType VARCHAR为参数#1设置非null时出错。尝试为此参数或其他配置属性设置不同的JdbcType。原因:java.sql.SQLException:列索引无效

参数映射

<parameterMap type="userDefVO" id="userDefVO">

        <parameter property="userDefRole" javaType="string"
            jdbcType="VARCHAR" />
        <parameter property="userShortRole" javaType="string"
            jdbcType="VARCHAR"  />
        <parameter property="userDefRoleDesc" javaType="string"
            jdbcType="VARCHAR"  />
        <parameter property="sysRole" javaType="string"
            jdbcType="VARCHAR"  />

    </parameterMap>

这是我的选择查询

<select id="fetchUserDefRole" resultMap="defRoleVO"
        parameterMap="userDefVO">
        SELECT * FROM PARTY_ROLE_SETUP 
        <where>

            <if test='userDefRole != null and userDefRole != "" '>

                and USER_DEF_ROLE like '%' || #{userDefRole} || '%'

            </if>
            <if test='userShortRole != null and userShortRole != "" '>

                and USER_SHORT_ROLE = #{userShortRole}

            </if>
            <if test='userDefRoleDesc != null and userDefRoleDesc != "" '>

                and USER_DEF_ROLE_DESC like '%' || #{userDefRoleDesc} || '%'

            </if>
            <if test='sysRole != null and sysRole != "" '>

                and SYSTEM_ROLE  = #{sysRole}

            </if>

        </where>

    </select>

这是数据库表

USER_DEF_ROLE      NOT NULL VARCHAR2(10)  
USER_SHORT_ROLE             VARCHAR2(10)  
USER_DEF_ROLE_DESC          VARCHAR2(120) 
SYSTEM_ROLE                 VARCHAR2(10) 

请帮助我知道此代码中的错误以及导致无效列索引异常的原因

0 个答案:

没有答案