반응형

Spring 2.5 + iBatis 작업 중
select 결과를 저장하기 위해 다음과 같이 작성했습니다.

<select id="SQL-LIST" parameterClass="java.util.Map" resultClass="java.util.Map">
SELECT ...
</select> 

그렇게 하니
다음의 에러가 발생하더군요.

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];  
--- The error occurred in /sql/CommunityMDAO.xml. 
--- The error occurred while applying a result map. 
--- Check the Community.SQL-LIST-AutoResultMap. 
--- Check the result mapping for the 'UPT_DATE' property. 
--- Cause: java.lang.RuntimeException: JavaBeansDataExchange could not instantiate result class.  Cause: java.lang.InstantiationException: java.util.Map; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in /sql/CommunityMDAO.xml. 
--- The error occurred while applying a result map. 
--- Check the Community.SQL-LIST-AutoResultMap. 
--- Check the result mapping for the 'UPT_DATE' property. 
--- Cause: java.lang.RuntimeException: JavaBeansDataExchange could not instantiate result class.  Cause: java.lang.InstantiationException: java.util.Map

java의 Map의 경우 interface 이다 보니
초기화에 실패하는 문제가 발생하더군요..

parameterClass 의 경우에는
인터페이스로 선언만 하면 전달인자에 의해서 자동으로 변환이 되지만,
resultClass 는 실존하는 형태로 제공이 되어야만 초기화가 가능한 것 같습니다.

그래서 다음과 같이 수정했습니다.

<select id="SQL-LIST" parameterClass="java.util.Map" resultClass="java.util.HashMap">
SELECT ...
</select>

이렇게 수정하고 나니
해결이 문제 없이 표기 되더군요..

별도의 DTO 생성 없이 하려다 보니
이런 문제가 생겼네요...

이거 때문에 2시간은 그냥 보낸 듯... ^^;;

참고:
http://blog.daum.net/_blog/BlogTypeView.do?blogid=09j4R&articleno=17200835#ajax_history_home
반응형

+ Recent posts