无效的列类型: getInt not implemented for class .T4CRowidAccessor

时间:2025-03-26 17:40:29

症状:

SpringMVC+MyBatis向数据库插入数据,主键应用ORACLE中自己设置的自增序列会发生如下错误:

SQL state [99999]; error code [17004]; 无效的列类型: getInt not implemented for class .T4CRowidAccessor; 

nested exception is : 无效的列类型: getInt not implemented for class .T4CRowidAccessor


解决办法:

相应实体类映射文件,如中

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
 PUBLIC "-////DTD Mapper 3.0//EN"
"/dtd/">
<mapper namespace="">
	<insert  parameterType="" useGeneratedKeys="true" keyProperty="id">
		insert into users(ID,name,password) values (USERS_SEQUENCE.NEXTVAL,#{name,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR})
	</insert>
</mapper>
把insert 属性里的useGeneratedKeys的属性设置为false就可以成功插入数据了,useGeneratedKeys 要求数据库本身具备主键自动增长的功能,
比如说,mysql,sqlserver可以使用useGeneratedKeys =true 这功能,oracle不支持useGeneratedKeys,所以ORACLE是不能使用useGeneratedKeys =true的。