1.写了一个批量插入的方法,插入的时候一直报有个参数找不到。
Caused by: org.apache.ibatis.binding.BindingException: Parameter 'communityId' not found. Available parameters are [list]
at org.apache.ibatis.session.defaults.DefaultSqlSession$StrictMap.get(DefaultSqlSession.java:261) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:44) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:76) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:47) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141) ~[mybatis-3.2.7.jar:3.2.7]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358) ~[mybatis-spring-1.2.2.jar:1.2.2]
... 41 common frames omitted
<insert id="insertBatch">
insert into n_biz_user_statistics (id, cur_date, num,
total,community_id,row_add_time, row_update_time
)
values
<foreach collection="list" index="index" item="item" separator=",">
(#{item.id,jdbcType=BIGINT}, #{item.curDate,jdbcType=DATE}, #{item.num,jdbcType=INTEGER},
#{item.total,jdbcType=INTEGER},#{communityId,jdbcType=BIGINT}, #{item.rowAddTime,jdbcType=TIMESTAMP},
#{item.rowUpdateTime,jdbcType=TIMESTAMP}
)
</foreach>
</insert>
仔细检查查发现#{communityId,jdbcType=BIGINT}这里写错了,应该是#{item.communityId,jdbcType=BIGINT}才对。
网友评论