报错信息:
Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='__frch_syncMsgDTO_0.callOwner', mode=IN, javaType=class java.lang.String, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #5 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111
报错原因:
主要看一下这里 property=’__frch_syncMsgDTO_0.callOwner 是因为这个值为 null 了,因为是不知道 Java 里的 null 属于啥类型,Mybatis 会认为属于 Other 类型,所以报错。postgreSQL,MySQL,SQLSERVER都支持JdbcType.NULL类型,Oracle是不支持,适配的时候也因为这个问题导致mybatis报错。
解决方案:
修改前:
<insert id="insertSyncMsgBatch">
insert into C##DEMO.zx_chl_callmsg_doc( CREDATE, COMEFROM, CALLNO, CALLOWNER, MSG, SOURCEID, SENDERID, SENDDEPTID, SENDDATE, USESTATUS, MEMO, SYNCFLAG)
<foreach collection="list" open="(" close=")" item="syncMsgDTO" index="index" separator="union all">
select
#{syncMsgDTO.creDate},
#{syncMsgDTO.comeFrom},
#{syncMsgDTO.callNo},
#{syncMsgDTO.callOwner},
#{syncMsgDTO.msg},
#{syncMsgDTO.sourceId},
#{syncMsgDTO.senderId},
#{syncMsgDTO.sendDeptId},
#{syncMsgDTO.sendDate},
#{syncMsgDTO.userStatus},
#{syncMsgDTO.memo},
#{syncMsgDTO.syncFlag}
from dual
</foreach>
</insert>
修改后:
<insert id="insertSyncMsgBatch">
insert into C##DEMO.zx_chl_callmsg_doc( CREDATE, COMEFROM, CALLNO, CALLOWNER, MSG, SOURCEID, SENDERID, SENDDEPTID, SENDDATE, USESTATUS, MEMO, SYNCFLAG)
<foreach collection="list" open="(" close=")" item="syncMsgDTO" index="index" separator="union all">
select
#{syncMsgDTO.creDate},
#{syncMsgDTO.comeFrom},
#{syncMsgDTO.callNo},
#{syncMsgDTO.callOwner,jdbcType=VARCHAR},
#{syncMsgDTO.msg},
#{syncMsgDTO.sourceId},
#{syncMsgDTO.senderId},
#{syncMsgDTO.sendDeptId},
#{syncMsgDTO.sendDate},
#{syncMsgDTO.userStatus},
#{syncMsgDTO.memo},
#{syncMsgDTO.syncFlag}
from dual
</foreach>
</insert>
评论前必须登录!
注册