[์๋ฌ] Spring / There is no getter for property named
๊ฐ๋ฐํ๊ฒฝ : STS (Spring Legacy Project)
์นดํ ๊ณ ๋ฆฌ ๊ธฐ๋ฅ ๊ตฌํ ์ค "There is no getter for property named 'category(์ปฌ๋ผ๋ช )' in 'class.java.lang.String'" ์ด๋ผ๋
์๋ฌ๊ฐ ๋ฐ์ํ๋ค. ์ฐธ๊ณ ํ๋ ์๋ฃ์ ๋์ผํ๊ฒ ์ฟผ๋ฆฌ๋ฌธ์ ์์ฑํ๊ณ , SqlDeveloper ์์๋ ๋์๊ฐ๋๋ฐ..
๊ทธ๋ฌ๋ but..! ๋๋ฒจ๋กํผ์์๋ ์ ๋์๊ฐ๋ ์ฟผ๋ฆฌ๋ฌธ์๋ ์ด์์ด ์์๊ณ , ๋ฌธ์ ๋ ์๋์ ์ฝ๋์ ์์๋ค.
<--! ์๋ฌ๊ฐ ๋ฐ์ํ ์ฝ๋ -->
<select id="countTagList" parameterType="String" resultType="int">
select count(*) from product
<if test="category != null and category != ''">
where cateGory = #{category}
</if>
</select>
ํ๋ผ๋ฏธํฐ ํ์ ์ด String ์ด๋ฉด์ ๋์ด์จ ํ๋ผ๋ฏธํฐ๋ช category๋ฅผ ๋์ if๋ฌธ์ผ๋ก ๋ฐ์ ๊ฒฝ์ฐ์ ๋ฐ์ํ ์๋ฌ๋ผ๊ณ ํ๋ค.
๋์ ์ฟผ๋ฆฌ์์ if๋ฌธ์ ํ๋ผ๋ฏธํฐ ํ์ ํด๋์ค์ getter๋ฅผ ํธ์ถํ๋ ๋ฐฉ์์ธ๋ฐ,
String ๋ด๋ถ์๋ getter ๊ฐ๋ ์ด ์ ์๋์ด ์์ง ์๋ค๊ณ ํ๋ค.
๋ฐ๋ผ์, parameter๋ฅผ cateGory๋ก ๋ณด๋์ด๋ ๋ง์ด๋ฐํฐ์ค์์ ๋จ์ผ๊ฐ์ผ ๊ฒฝ์ฐ ์์์ value๋ก ๋ฐ์์ฃผ๋ฉด ์ฒ๋ฆฌ ๊ฐ๋ฅ.
<!-- ์์ ํ ์ฝ๋ 1 -->
<select id="countTagList" parameterType="String" resultType="int">
select count(*) from product
where 1=1
<if test="value != null and value != ''">
and prd_category = #{value}
</if>
</select>
ํญ์ ์ฐธ์ ์๋ฏธํ๋ "where 1=1" ์ ๊ด๋ จํด์๋ ์ฌ์ฉ์ ์ง์ํด์ผํ๋ค ์๋๋ค ์๊ฒฌ์ด ์ข ์๋ ๊ฒ ๊ฐ์์
๊ณต๋ถ๋ฅผ ๋ ํด๋ด์ผ๊ฒ ์ง๋ง, where์ ์ ์๋์ ๊ฐ์ด ํํํ ์๋ ์๋ค๊ณ ํ๋ค.
๊ฒฐ๊ณผ๋ ์ ์ฝ๋์ ๋์ผํ๋ค.
<!-- ์์ ํ ์ฝ๋ 2 -->
<select id="countTagList" parameterType="String" resultType="int">
select count(*) from product
<where>
<if test="value != null and value != ''">
and prd_category = #{value}
</if>
</where>
</select>
์ฐธ๊ณ ) ์๋ฌ๋ฉ์ธ์ง ๊ด๋ จ
https://bcdragonfly.tistory.com/10
[mybatis] There is no getter for property named : ํ๋ผ๋ฏธํฐ ํ๋ ์ผ๋ ์๋ฌ
org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'param' in 'class java.lang.String' ๋ถ๋ช ํ ํ๋ผ๋ฏธํฐ๋ฅผ ์ ๋๊ฒจ์ฃผ์๊ณ ๋ง์ด๋ฐํฐ์ค์์๋ ์ ๋ฐ์๋๋ฐ๋ ๋ถ๊ตฌํ๊ณ ... ํฉ๋นํ ์๋ฌ๊ฐ ๋จ
bcdragonfly.tistory.com
์ฐธ๊ณ ) ๋ง์ด๋ฐํฐ์ค ๋์ ์ฟผ๋ฆฌ ๊ด๋ จ
Mybatis(๋ง์ด๋ฐํฐ์ค) ๋์ ์ฟผ๋ฆฌ if๋ฌธ ๋ฌธ๋ฒ, Mybatis(๋ง์ด๋ฐํฐ์ค) <if> ์ฌ์ฉ๋ฒ, Mybatis(๋ง์ด๋ฐํฐ์ค) <if>์ฌ
Mybatis(๋ง์ด๋ฐํฐ์ค) ๋์ ์ฟผ๋ฆฌ if๋ฌธ ๋ฌธ๋ฒ, Mybatis(๋ง์ด๋ฐํฐ์ค) ์ฌ์ฉ๋ฒ, Mybatis(๋ง์ด๋ฐํฐ์ค) ์ฌ์ฉ๋ฐฉ๋ฒ, Mybatis(๋ง์ด๋ฐํฐ์ค) if ๊ฒ์ฌ๋ฐฉ๋ฒ Mybatis(๋ง์ด๋ฐํฐ์ค)๋ DBMS์์ธ์ค๋ฅผ ์ฝ๊ฒ ์ฌ์ฉํ ์ ์๊ฒ ํด์ฃผ๋ Java
devscb.tistory.com
์ฐธ๊ณ ) where 1=1 ๊ตฌ๋ฌธ ๊ด๋ จ
Oracle WHERE 1=1 ๊ตฌ๋ฌธ์ ๋ํ์ฌ :: JDM's Blog
์ด๋ฒ์ ์ค๋ผํด์์ WHERE 1=1์ ๋ํ์ฌ ํฌ์คํ ์ ํด๋ณด๋ ค๊ณ ํ๋ค. ๊ทธ๋ฐ๋ฐ ํด๋น ํฌ์คํ ์ ์ด๋ฏธ ๋ค์ด๋ฒ ๋ธ๋ก๊ทธ์์ ํ๋ฒ ํ์๋ค(2013.03.18). ํ์ง๋ง ์๋ ๊ฒ์ด๊ธฐ๋ ํ๊ณ ์ง๊ธ์ ๊ฐ๋ฐ๋ ฅ(?)์ด ์กฐ๊ธ์ ์์น
jdm.kr