MyBatis Parameter not found

遇到一个很牛X的问题。当MyBatis的foreach中item='cr'时,程序居然抛出异常:
19:07:55.338 DEBUG c.l.dao.PageMapper.selectByCriteria - ==>  Preparing: select id, pag_id, title, content, status, create_date, modified_date from page WHERE ( pag_id = ? and status = ? ) order by modified_date desc 
19:07:55.378 DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3f68f2a4]
19:07:55.379 DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
19:07:55.382 DEBUG o.a.struts2.dispatcher.Dispatcher - Exception occurred during processing request: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch___frch_cr_0iterion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch___frch_cr_0iterion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]
    ……
Caused by: org.apache.ibatis.binding.BindingException: Parameter '__frch___frch_cr_0iterion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]
    ……
当把cr改成c后,程序依然异常:
19:11:35.496 DEBUG c.l.dao.PageMapper.selectByCriteria - ==>  Preparing: select id, pag_id, title, content, status, create_date, modified_date from page WHERE ( pag_id = ? and status = ? ) order by modified_date desc 
19:11:35.531 DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@270b6d1c]
19:11:35.532 DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
19:11:35.534 DEBUG o.a.struts2.dispatcher.Dispatcher - Exception occurred during processing request: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__fr__frch_c_0h_criterion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__fr__frch_c_0h_criterion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]
……
Caused by: org.apache.ibatis.binding.BindingException: Parameter '__fr__frch_c_0h_criterion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]
    
当改成cri后,异常依旧在:
19:13:33.702 DEBUG c.l.dao.PageMapper.selectByCriteria - ==>  Preparing: select id, pag_id, title, content, status, create_date, modified_date from page WHERE ( pag_id = ? and status = ? ) order by modified_date desc 
19:13:33.740 DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@76d56dba]
19:13:33.740 DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
19:13:33.742 DEBUG o.a.struts2.dispatcher.Dispatcher - Exception occurred during processing request: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch___frch_cri_0terion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch___frch_cri_0terion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]
……
Caused by: org.apache.ibatis.binding.BindingException: Parameter '__frch___frch_cri_0terion_1' not found. Available parameters are [col, param1, page, param2, param3, wcriteria]

当改成criteria后,程序就正常了,起初我还以为是item对长度有限值,可是没听说啊。于是决定把cr改成ab试一下,奇迹不总是发生在长度上,居然没有异常。不晓得MyBatis是不是在哪个不起眼的地方对这个问题有说明,也或许他是一个bug,不管是哪种情况,如果你也遇到了,希望对你有帮助。

转载于:https://www.cnblogs.com/MagicLetters/p/3444273.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值