场景:批量插入,自增主键,数据入库正常,抛出异常:

    org.apache.ibatis.binding.BindingException: Parameter ‘id’ not found. Available parameters are [list]
    _

    1. 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]
    2. at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:63)
    3. at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processAfter(Jdbc3KeyGenerator.java:42)
    4. at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:45)
    5. at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
    6. at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
    7. at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
    8. at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
    9. at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
    10. at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:137)
    11. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    12. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    13. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    14. at java.lang.reflect.Method.invoke(Method.java:498)
    15. at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)
    16. ... 71 more
    17. Caused by: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [list]
    18. at org.apache.ibatis.session.defaults.DefaultSqlSession$StrictMap.get(DefaultSqlSession.java:257)
    19. at org.apache.ibatis.reflection.wrapper.MapWrapper.getSetterType(MapWrapper.java:76)
    20. at org.apache.ibatis.reflection.MetaObject.getSetterType(MetaObject.java:88)
    21. at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.getTypeHandlers(Jdbc3KeyGenerator.java:79)
    22. at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:58)
    23. ... 84 more
    1. <sql id="sql">
    2. product_id,product_code,product_date,expire_date,status,branch_id,create_user,update_user,create_time,update_time
    3. </sql>
    4. <insert id="insertBatch" parameterType="com.huiwang.product.vo.ProInfoDetail" useGeneratedKeys="true" keyProperty="id">
    5. INSERT INTO product_info_detail(<include refid="sql" />) values
    6. <foreach item="item" collection="list" separator=",">
    7. (#{item.productId},#{item.productCode},#{item.productDate},#{item.expireDate},#{item.status},#{item.branchId},#{item.createUser},#{item.updateUser},now(),now())
    8. </foreach>
    9. </insert>

    去掉 useGeneratedKeys=”true” keyProperty=”id”


    场景:PageHelper 插件 报错
    java.lang.NoClassDefFoundError: Could not initialize class com.github.pagehelper.util.MetaObjectUtil

    1. 涓ラ噸: 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 cause
    2. java.lang.NoClassDefFoundError: Could not initialize class com.github.pagehelper.util.MetaObjectUtil
    3. at com.github.pagehelper.dialect.AbstractHelperDialect.processParameterObject(AbstractHelperDialect.java:118)
    4. at com.github.pagehelper.PageHelper.processParameterObject(PageHelper.java:88)
    5. at com.github.pagehelper.util.ExecutorUtil.pageQuery(ExecutorUtil.java:166)
    6. at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:104)
    7. at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:57)
    8. at com.sun.proxy.$Proxy46.query(Unknown Source)
    9. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
    10. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
    11. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    12. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    13. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    14. at java.lang.reflect.Method.invoke(Method.java:498)
    15. at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)
    16. at com.sun.proxy.$Proxy13.selectList(Unknown Source)
    17. at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:205)
    18. at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)
    19. at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
    20. at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
    21. at com.sun.proxy.$Proxy30.selectByPage(Unknown Source)
    22. at com.huiwang.product.service.impl.ProductService.getProDetailByPage(ProductService.java:688)
    23. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    24. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    25. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    26. at java.lang.reflect.Method.invoke(Method.java:498)
    27. at or

    https://github.com/pagehelper/Mybatis-PageHelper/issues/340_https://github.com/pagehelper/Mybatis-PageHelper/issues/349

    这是分页插件兼容性没做好导致的,该问题已经解决,将要发布的 5.1.9 支持 mybatis 低版本。#349