查询数据库时出错。原因:java.lang.IllegalArgumentException:映射的语句集合不包含getSecurityRowCount的值

时间:2017-04-13 16:44:51

标签: java sql mybatis spring-mybatis

下面是我的mybatis.xml文件 -

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.principal.pfunds.service.rest.jdbcmanager.SecurityManagers">
<select id="getSecurityRowCount" parameterType="com.principal.pfunds.service.rest.mybatis.SecurityParam"
    resultType="java.lang.Integer">
    SELECT COUNT(*) ROWSCOUNT 
    FROM 
        ${schema}.A_PDC_SCRTY 
    WHERE 
        TOKEN_ID = #{tokenID}
        AND RSLT_TYP = #{resultType} 
        AND SVC_CD = #{svcCode}
</select>

我使用下面的代码语句调用此查询 -

Integer securityRowCount = getSqlSession().selectOne("getSecurityRowCount", securityParam); 

我正在尝试获取行计数,但它给出了错误:

Exception in getSecurityRowCount(): org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for getSecurityRowCount
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for getSecurityRowCount
[4/13/17 22:05:17:734 IST] 000000a4 SystemOut     O

请帮帮我。我无法理解这里出了什么问题。谢谢!

1 个答案:

答案 0 :(得分:0)

documentation中,语句由其完全限定名称(前缀语句id with namespace)引用:

selectOne("com.principal.pfunds.service.rest.jdbcmanager.SecurityManagers.getSecurityRowCount", securityParam);