zoukankan      html  css  js  c++  java
  • mybatis查询异常-Error querying database. Cause: java.lang.ClassCastException: org.apache.ibatis.executor.ExecutionPlaceholder cannot be cast to java.util.List

    背景,mybatis查询的时候直接取的sqlsession,没有包装成SqlSessionTemplate,没有走spring提供的代理。

    然后我写的获取sqlsession的代码没有考虑到并发的情况,导致sqlsession建的太多

    并发大了之后,查询报错

    org.apache.ibatis.exceptions.PersistenceException: 
    ### Error querying database.  Cause: java.lang.ClassCastException: org.apache.ibatis.executor.ExecutionPlaceholder cannot be cast to java.util.List
    ### The error may exist in class path resource [mybatis/ConVideoInfoMapper.xml]
    ### The error may involve com.letv.mms.core.dao.IConVideoInfoDao.selectById
    ### The error occurred while executing a query
    ### Cause: java.lang.ClassCastException: org.apache.ibatis.executor.ExecutionPlaceholder cannot be cast to java.util.List
            at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) ~[mybatis-3.1.1.jar:3.1.1]
            at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) ~[mybatis-3.1.1.jar:3.1.1]
            at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95) ~[mybatis-3.1.1.jar:3.1.1]
            at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:59) ~[mybatis-3.1.1.jar:3.1.1]
            at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:95) ~[mybatis-3.1.1.jar:3.1.1]
            at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40) ~[mybatis-3.1.1.jar:3.1.1]

    解决方法,交给spring来管理mybatis,使用sqlsessiontemplate。

  • 相关阅读:
    日常脚本练习与解释
    第五周作业
    centos 7中命令记录
    centos7 中如何查看、打开、关闭防火墙。
    第四周
    复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的 行首的空白字符
    vim中设置tab缩进为4个字符
    Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。
    sql 索引笔记--索引组织结构
    sql 索引笔记2
  • 原文地址:https://www.cnblogs.com/shamo89/p/9032484.html
Copyright © 2011-2022 走看看