SpringBoot
[MyBatis] update에서 selectKey가 안돼요! :: No setter found for the keyProperty '' in java.lang.String.
N'Che
2020. 7. 1. 16:20
제곧내...
<update id="companyBoardCountUpadate" parameterType="CompanyBoardContent">
<selectKey order="BEFORE" keyProperty="companyCount" resultType="String">
SELECT
c.company_count+1
from
tb_company AS c
where
c.company_code = #{companyCode}
</selectKey>
UPDATE tb_company
SET
company_count= #{companyCount}
WHERE
company_code = #{companyCode}
</update>
쿼리문도 전부 정상이고 오탈자도 없으며,, DTO에 알맞은 getter, setter도 전부 있었는데!!!!!!!!!!!
org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty 'companyCount' in java.lang.String.
이 오류로 인해 진행이 안되는 상황이었다..
조언도 구해봤는데 원인을 전혀 모르겠어서 서브쿼리로 처리했다...
마이바티스!!!!!! 나는 너를 믿었는데!!
그래도 서브쿼리로 바꾼 코드가 더 간결해서 기분이 좋아졌다 ~~ ^^~!!
<update id="companyBoardCountUpadate" parameterType="CompanyBoardContent">
UPDATE tb_company
SET
company_count= (SELECT company_count +1)
WHERE
company_code = #{companyCode}
</update>