본문 바로가기
IT 개발/에러

[MyBatis] foreach not found 에러

by Dev.Jeon 2023. 1. 9.
반응형

에러메시지

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

 

현상

AND A.FAC_STANDARD_CODE IN 
    <foreach collection="facCodeList" item="item" open="(" close=")" separator=",">
        #{item}
    </foreach>

 

원인

1. 파라미터 전달이 부정확하고, xml에서 정확히 전달 받지 못했을 경우

2. item이 null인 경우

 

해결

1.

item의 타입을 명시에 주자

AND A.FAC_STANDARD_CODE IN 
    <foreach collection="facCodeList" item="item" open="(" close=")" separator=",">
    	#{item,jdbcType=VARCHAR}
    </foreach>

2.

나의 경우는

facCodeList가 LIST<VO> 였기 때문에 단일 값이 아니라서 오류

VO에 어떤 값인지 명시해야 오류가 안 난다.

AND A.FAC_STANDARD_CODE IN 
    <foreach collection="facCodeList" item="item" open="(" close=")" separator=",">
        #{item.sysseq}
    </foreach>

 

참조사이트

 

https://devfootprint.tistory.com/44

 

[ Mybatis ] Type handler was null on parameter mapping for property '__frch_item_0.value'. 에러

에러 메시지 : Type handler was null on parameter mapping for property '__frch_item_0.value'. 에러 현상 : my batis foreach 문 사용시 에러가 발생 #{item.value} 원인 : parameter 전달이 부정확하고, xml에서 정확히 받지 못했

devfootprint.tistory.com

 

반응형

댓글