背景,mybatis查詢的時候直接取的sqlsession,沒有包裝成SqlSessionTemplate,沒有走spring提供的代理。java
而後我寫的獲取sqlsession的代碼沒有考慮到併發的狀況,致使sqlsession建的太多spring
併發大了以後,查詢報錯sql
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。apache