Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
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
Tags more
Archives
Today
Total
관리 메뉴

jeongwon

[Error] mybatis - There is no getter for property named 'table' in 'class java.lang.String' 본문

Error log

[Error] mybatis - There is no getter for property named 'table' in 'class java.lang.String'

jeongwon_ 2022. 11. 2. 15:20

오류: There is no getter for property named 'table' in 'class java.lang.String'

 

상황: mybatis 구문에서 테이블명을 변수로 받고자 함. 변수명은 ${table}로 설정.

 

- DAOImpl:

sqlSession.selectOne("admin.countReservAll", table);

 

- mybatis sql:

<select id="countReservAll" resultType="int">
select count(*) from ${table}
</select>

 

해결:

변수명을 ${valu} 로 설정.

mabatis parametertype에서 String을 쓰면 ${value} 작성시 getter 역할을 한다고.

다만 Sql Injection 대비 (사용자의 입력이 DB Query 에 동적으로 영향을 주는 경우, 입력된 값이 개발자가 의도한 값(요효값) 인지 검증)가 필요하다고 한다.