XML文件中配置如下
<insert id="insertMSG" parameterType="com.test.XXX">
insert into XXXXXX (msg_def_id)
select
#{msg_def_id,jdbcType=VARCHAR} from dual
</insert>
发生报错:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='msg_def_id', 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 non null for parameter #3 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: 无效的列索引
报错的意思是非空值并不能使用JdbcType=null,可问题是这里已经给这个字段配置了jdbcType=VARCHAR,请问这是什么原因?数据库是oracle