您的位置:首页 > 其它

mybatis常见错误

2014-12-05 11:45 225 查看
第一个错误  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: 无效字符

注: 无效的列类型  “;”  
        无效的列类型    参数为 null
映射文件中,语句末尾多了分号导致的。

第三个错误

mybatis Mapped Statements collection already contains value

mybatis并发错误,前台多个请求并发请求mapper

原因大概是请求时mybaits解析sql并执行导致的并发错误。

mybaits初始化时加上以下这句可以解决。让Mybatis初始化时就编译sql语句。

sqlSesssionTemplate.getConfiguration().buildAllStatement
 
第四个错误   
                               无效的列索引    :  解决  #   用 $ 替换 。    
        原因:例    to_date(      #{end}    ,     'yyyy-mm-dd hh24:mi:ss')   正确

                            to_date(      '#{end}'   ,     'yyyy-mm-dd hh24:mi:ss')   错误
                            to_date(      ${end}    ,      'yyyy-mm-dd hh24:mi:ss')   错误

                            to_date(      '${end}'  ,       'yyyy-mm-dd hh24:mi:ss')   正确
    注意 单引号
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: