场景:批量插入,自增主键,数据入库正常,抛出异常:
org.apache.ibatis.binding.BindingException: Parameter ‘id’ not found. Available parameters are [list]
_
Caused by: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [list]at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:63)at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processAfter(Jdbc3KeyGenerator.java:42)at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:45)at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:137)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)... 71 moreCaused by: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [list]at org.apache.ibatis.session.defaults.DefaultSqlSession$StrictMap.get(DefaultSqlSession.java:257)at org.apache.ibatis.reflection.wrapper.MapWrapper.getSetterType(MapWrapper.java:76)at org.apache.ibatis.reflection.MetaObject.getSetterType(MetaObject.java:88)at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.getTypeHandlers(Jdbc3KeyGenerator.java:79)at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:58)... 84 more
<sql id="sql">product_id,product_code,product_date,expire_date,status,branch_id,create_user,update_user,create_time,update_time</sql><insert id="insertBatch" parameterType="com.huiwang.product.vo.ProInfoDetail" useGeneratedKeys="true" keyProperty="id">INSERT INTO product_info_detail(<include refid="sql" />) values<foreach item="item" collection="list" separator=",">(#{item.productId},#{item.productCode},#{item.productDate},#{item.expireDate},#{item.status},#{item.branchId},#{item.createUser},#{item.updateUser},now(),now())</foreach></insert>
去掉 useGeneratedKeys=”true” keyProperty=”id”
场景:PageHelper 插件 报错
java.lang.NoClassDefFoundError: Could not initialize class com.github.pagehelper.util.MetaObjectUtil
涓ラ噸: Servlet.service() for servlet [spring] in context with path [/store] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.github.pagehelper.util.MetaObjectUtil] with root causejava.lang.NoClassDefFoundError: Could not initialize class com.github.pagehelper.util.MetaObjectUtilat com.github.pagehelper.dialect.AbstractHelperDialect.processParameterObject(AbstractHelperDialect.java:118)at com.github.pagehelper.PageHelper.processParameterObject(PageHelper.java:88)at com.github.pagehelper.util.ExecutorUtil.pageQuery(ExecutorUtil.java:166)at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:104)at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:57)at com.sun.proxy.$Proxy46.query(Unknown Source)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)at com.sun.proxy.$Proxy13.selectList(Unknown Source)at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:205)at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)at com.sun.proxy.$Proxy30.selectByPage(Unknown Source)at com.huiwang.product.service.impl.ProductService.getProDetailByPage(ProductService.java:688)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at or
https://github.com/pagehelper/Mybatis-PageHelper/issues/340_https://github.com/pagehelper/Mybatis-PageHelper/issues/349
这是分页插件兼容性没做好导致的,该问题已经解决,将要发布的 5.1.9 支持 mybatis 低版本。#349
