참고 URL : http://blog.naver.com/PostView.nhn?blogId=roropoly1&logNo=221184569655&parentCategoryNo=&categoryNo=9&viewDate=&isShowPopularPosts=true&from=search
mybatis 를 사용할때 맵이나 VO를 사용할 경우에는
해당 변수명으로 그대로 사용해서 값을 꺼내오거나 수정할 수 있음
=====================================================================================================================================================
UPDATE securus_dept SET dept_par_id = ${parentDeptId} , dept_level = ${deptLevel} WHERE dept_id = ${deptId}
=====================================================================================================================================================
맵을 사용하지 않고 단일 변수로 값을 보낼경우에는 변수명으로 접근이 불가능함
ex) 서비스 단에서 값을 보낼때, 아래와같이 deptStatus 라는 int 형 변수를 넘김
=====================================================================================================================================================
public int getTotalCount(int deptStatus){
return sqlSession.selectOne(namespace+".getTotalCount" , deptStatus);
}
=====================================================================================================================================================
맵퍼에서 아래의 방법으로 해당 값으로 변수를 가져오려고 하면 에러가 발생함
=====================================================================================================================================================
SELECT count(*) AS totalPage FROM securus_dept WHERE dept_status = ##{deptStatus}
=====================================================================================================================================================
에러 코드
=====================================================================================================================================================
There is no getter for property named 'deptStatus' in 'class java.lang.Integer'
=====================================================================================================================================================
단일 변수로 값을 넘겼을 경우에는 value 를 사용
넘긴 변수명이 어떻게 되었든 간에 value 로 명시하면 알아서 값을 매칭시켜 가져온다
=====================================================================================================================================================
SELECT count(*) AS totalPage FROM securus_dept WHERE dept_status = ##{value}
=====================================================================================================================================================