간단하게 정리하면 다음과 같이 정리할 수 있다.
DAO에서
public ArrayList<Gantt> getGantt(int project_id);
로 생성하엿다면
mapper에서는
resultType을 VO명으로 (gantt) 만들어야하고,
ParamterType은 전달받을 파라미터인 int로 명시 하여야 한다.
parameterType을 사용하는 방법
resultMap은 VO에 명시된 값과 DB 컬럼 값을 다르게 할때 매핑할 용도로 주로 사용한다.
ex)
<resultMap type="gantt" id="ganttResult">
<result property="open" column="open1"/>
</resultMap>
<select id="getGantt" resultMap="ganttResult" parameterType="int">
select project_num,id, start_date, duration, text, progress, sortorder, parent, open1
from gantt
where project_num = #{project_num}
</select>
API를 쓰다보면 open과 같은 미리 정해진 명칭을 사용해야 할 때가 있다.
오라클에서는 OPEN 이라는 이름으로 컬럼을 생성 할 수 없는데,
위와같이 <result property="open" column="open1"/>
처럼 쓰면
다른 OPEN1이라고 DB컬럼명을 만들고 OPEN이라고 VO에서 사용하겠다는 것이다.
그 다음 사용 할때는 <select id="getGantt" resultMap="ganttResult" parameterType="int">
와 같이 resultMap에 정해놓은 명을 입력 해 주면 된다.