在做insert的时候报这种错误
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='demolition', 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 #8 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (8 > number of parameters, which is 7).
dao层代码
LandRecommend addLandRecommend(LandRecommend landRecommend);
mapper.xml
<sql id="allFields">
id,province,city,district,address,area_covered,volume,
attachment,demolition,price,remarks,cooperation_mode,file_address,
user_name,user_phone,create_time
</sql>
<insert id="addLandRecommend" parameterType="landRecommend">
insert into land_recommend
(<include refid="allFields"/>)
values(#(id),#{province},#{city},#{district},#{address},#{areaCovered},
#{volume},#{attachment},
#{demolition},#{price},#{remarks},#{cooperationMode},
#{fileAddress},#{userName},#{userPhone},now())
</insert>
数据现在能正常插入到表里面,但是报出来这种错
org.apache.ibatis.binding.BindingException: Mapper method 'com.xx.xxx.xxx.LandRecommendDao.addLandRecommend' has an unsupported return type: class com.xxx.xxx.xxx.LandRecommend
好像是 demolition 这个参数的数据类型有问题. 设置个int或者bigint?
(8 > number of parameters, which is 7).参数数量少了,你看下少了什么.
另外#(id),不应该是#{id}吗
还有你需要对参数进行非空处理
先把打印出来的sql语句和参数复制出来放到navicat里去试试,,这样能更直观看出是什么问题
Parameter index out of range 参数数量不对。
不知道你的问题修改了啥,之前的错误就是你要插入的字段数量和你给的值数量不一致
LandRecommend addLandRecommend(LandRecommend landRecommend);
把这个返回值改成int或者void,insert插入不支持返回实体对象