티스토리 뷰

Error updating database.  Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property 
It was either not specified and/or could not be found for the javaType / jdbcType combination specified.

[2023-06-09 18:04:25] INFO  [http-bio-8080-exec-5] jdbc.sqlonly     (Log4JdbcCustomFormatter.java:74)     - SQL : select LAST_INSERT_ID()
[2023-06-09 18:04:25] INFO  [http-bio-8080-exec-5] jdbc.connection  (Slf4jSpyLogDelegator.java:543)     - 77. Connection closed
[2023-06-09 18:04:25] ERROR [http-bio-8080-exec-5] util.CommonUtil  (CommonUtil.java:373)     - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property '__frch_SN_0'.  It was either not specified and/or could not be found for the javaType / jdbcType combination specified.
### Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property '__frch_SN_0'.  It was either not specified and/or could not be found for the javaType / jdbcType combination specified.
[2023-06-09 18:04:25] ERROR [http-bio-8080-exec-5] util.CommonUtil  (CommonUtil.java:376)     - org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:76)
[2023-06-09 18:04:25] ERROR [http-bio-8080-exec-5] util.CommonUtil  (CommonUtil.java:376)     - org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:399)
[2023-06-09 18:04:25] ERROR [http-bio-8080-exec-5] util.CommonUtil  (CommonUtil.java:376)     - jdk.proxy3/jdk.proxy3.$Proxy35.update(Unknown Source)
[2023-06-09 18:04:25] ERROR [http-bio-8080-exec-5] util.CommonUtil  (CommonUtil.java:376)     - org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:269)

copy & paste를 열심히 했더니 위와 같은 에러가 발생하였다.

흠.. 항상 직접 개발을 안 하고 기존 소스 복사, 붙여넣기를 하면 이런 에러가 발생한다.

javaType /jdbcType 이라는 말이 나온것을 보면 뭔가 타입이 안맞다는 것인데...

타입에 초점을 맞춰서 생각과 디버깅을 해본다.

뭔가 myBatis나 framework 등에서 제공하는 틀이 있는데 그 틀 사용법에 맞지 않게 사용을 하려고 해서 그런것 같은 느낌이 든다.

즉, 그 틀에 맞는 형식(Type) 이 있는데 그 형식에 맞지 않게 사용하려고 해서..

javaType / jdbcType combination 즉, 자바 타입과 jdbc 타입 조합이 안맞다고 한다.

그럼 그 조합을 맞춰주면 되겠네..

myBatis 에서
<foreach collection="" item="" index="index" separator="," open="(" close=")">
</foreach>
를 사용하려고 하는데

collection에는 순수 값만 있는 리스트로 되어야 하는데
복사 붙여넣기를 하다보니까 Map이 있는 리스트가 있었다.

그래서 타입이 안맞다고 했구나..

그래서 맵 대신에 순수 데이터만 있는 리스트로 바꿔주니 잘 되었다.

기존 리스트를 받아올 때 썼던
<select id="getSn" parameterType="hashMap" resultType="hashMap" > 
이 부분을 아래 처럼 resultType="String"으로 순수 스트링만 리턴하게 바꾸었다.
<select id="getSn" parameterType="hashMap" resultType="String" >

myBatis에서 foreach collection을 사용할 때는 resultType="String" 으로 받아서 리스트를 만들어 줘야 한다.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함