首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

Mybatis常见异常

2012-07-04 
Mybatis常见错误第一个错误Mapped Statements collection does not contain value for ......可以如下查找

Mybatis常见错误
第一个错误  Mapped Statements collection does not contain value for ......
可以如下查找错误
1、映射文件 例如People.xml的namespace是否指向正确的mapper
2、2个映射文件的namespace不可以相同
3、查询语句中 getSqlSession().selectList(path); 查询路径是否有错。
4、映射文件中的每一个映射语句的id是否正确


第二个错误

org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: 
--- The error occurred in com/ivo/etl/stg/model/Pubca.xml.
--- The error occurred while applying a parameter map.
--- Check the s_pub_getPubca-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: java.sql.SQLException: ORA-00911: 无效字符
Caused by: java.sql.SQLException: ORA-00911: 无效字符

映射文件中,语句末尾多了分号导致的。

第三个错误

mybatis Mapped Statements collection already contains value

mybatis并发错误,前台多个请求并发请求mapper
原因大概是请求时mybaits解析sql并执行导致的并发错误。
mybaits初始化时加上以下这句可以解决。让Mybatis初始化时就编译sql语句。

sqlSesssionTemplate.getConfiguration().buildAllStatement

热点排行