문제 상황
Mybatis + MariaDB 연동 중에 아래와 같이 PersistenceException 관련 에러가 발생하였다.
에러로그
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.test.CountValue
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.test.CountValue
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at com.sun.proxy.$Proxy25.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:237)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy29.countValue(Unknown Source)
....
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.test.CountValue
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.test.CountValue
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
... 64 more
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.test.CountValue
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:660)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:495)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:488)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:144)
... 70 more
test.xml
<select id="getcount" parametertype="java.lang.String" resulttype="java.lang.Integer">
SELECT COUNT(*)
FROM testvalue
WHERE valueID = #{valueID}
</select>
test.java
@Override
public long getCount(String valueID) throws Exception {
long cnt = 0;
cnt = (long)query.selectOne(Name + "getCount", valueID);
return cnt;
}
문제 원인
test.java와 test.xml에서 사용한 id의 대소문자 값이 동일하지 않았다. (스펠링은 같음)
혹시나 스펠링이 다를까봐 ctrl+C로 id 복사 후 찾아 봤을 때도 잘 검색이 되었기 때문에 에러인지 바로 인식을 못했다.
별것 아니지만 이런류의 에러가 시간+에너지를 잡아먹기 딱 좋은듯 하다.
문제 해결
test.xml
<select id="getCount" parameterType="java.lang.String" resultType="java.lang.Long">
SELECT COUNT(*)
FROM testvalue
WHERE valueID = #{valueID}
</select>
[Maven] Websocket 연동 시 java.lang.ClassCastException 에러 (0) | 2015.11.23 |
---|---|
[MyBatis] invokeJoinpointUsingReflection 에러 (0) | 2015.06.15 |
[Oracle] DEFAULT ON NULL (0) | 2014.01.21 |
ORA-38104: Columns referenced in the ON Clause cannot be updated (0) | 2013.12.18 |
ORA-00918: 열의 정의가 애매합니다 (0) | 2013.12.16 |
댓글 영역