왼쪽(중요한 거=>left조인) 오른쪽(없을 수도 있는 거) 균형 맞춰줘야 함
오라클)
SELECT A.BOOK_ID, A.TITLE, A.CATEGORY, A.PRICE, A.INSERT_DATE, A.CONTENT
, B.ATCH_FILE_ID, B.FILE_SN, B.FILE_STRE_COURS, B.STRE_FILE_NM, B.ORIGNL_FILE_NM, B.FILE_EXTSN, B.FILE_CN, B.FILE_SIZE
FROM BOOK A, ATCH_FILE_DETAIL B
WHERE A.BOOK_ID = B.ATCH_FILE_ID(+)
AND A.BOOK_ID = 'BK0001';
ANSI)
SELECT A.BOOK_ID, A.TITLE, A.CATEGORY, A.PRICE, A.INSERT_DATE
, A.CONTENT
, B.ATCH_FILE_ID, B.FILE_SN, B.FILE_STRE_COURS, B.STRE_FILE_NM, B.ORIGNL_FILE_NM
, B.FILE_EXTSN, B.FILE_CN, B.FILE_SIZE
FROM BOOK A LEFT OUTER JOIN ATCH_FILE_DETAIL B ON(A.BOOK_ID = B.ATCH_FILE_ID)
WHERE A.BOOK_ID = 'BK0001';
부족한 쪽에 (+) 붙임
private String eEmpno;
private String eName;
private String eAddress;
private String eTelno;
private String ePosition;
private String eDept;
private int rnum;
private String atchFileId;
private int fileSn;
private String fileStreCours;
private String streFileNm;
private String orignlFileNm;
private String fileExtsn;
private String fileCn;
private int fileSize;
==>1:1 관계밖에 안됨 ==> Map 으로 형식 바꿔
=> .xml에 resultMap 생성
<resultMap type="employeeVO" id="employeeMap">
<result property="eEmpno" column="E_EMPNO"/>
<result property="eName" column="E_NAME"/>
<result property="eAddress" column="E_ADDRESS"/>
<result property="eTelno" column="E_TELNO"/>
<result property="ePosition" column="E_POSITION"/>
<result property="eDept" column="E_DEPT"/>
</resultMap>
<select id="detail" parameterType="employeeVO" resultMap="employeeMap">
SELECT A.E_EMPNO, A.E_NAME, A.E_ADDRESS, A.E_TELNO, A.E_POSITION, A.E_DEPT
, B.ATCH_FILE_ID, B.FILE_SN, B.FILE_STRE_COURS, B.STRE_FILE_NM, B.ORIGNL_FILE_NM, B.FILE_EXTSN, B.FILE_CN, B.FILE_SIZE
FROM EMPLOYEE A LEFT OUTER JOIN ATCH_FILE_DETAIL B ON(A.E_EMPNO = B.ATCH_FILE_ID)
WHERE A.E_EMPNO = #{eEmpno}
</select>
=> 리스트니까 collection 추가
<result property="eDept" column="E_DEPT"/>
<collection property="atchFileDetailVOList" resultMap="atchFileDetailMap"></collection>
</resultMap>
=> 들어갈 곳 처리 --resultMap="atchFileDetailMap" => 이거 정의
<collection property="atchFileDetailVOList" resultMap="atchFileDetailMap"></collection>
</resultMap>
<resultMap type="atchFileDetailVO" id="atchFileDetailMap">
<result property="atchFileId" column="ATCH_FILE_ID"/>
<result property="fileSn" column="FILE_SN"/>
<result property="fileStreCours" column="FILE_STRE_COURS"/>
<result property="streFileNm" column="STRE_FILE_NM"/>
<result property="orignlFileNm" column="ORIGNL_FILE_NM"/>
<result property="fileExtsn" column="FILE_EXTSN"/>
<result property="fileCn" column="FILE_CN"/>
<result property="fileSize" column="FILE_SIZE"/>
</resultMap>
<select id="detail" parameterType="employeeVO" resultMap="employeeMap">
SELECT A.E_EMPNO, A.E_NAME, A.E_ADDRESS, A.E_TELNO, A.E_POSITION, A.E_DEPT
, B.ATCH_FILE_ID, B.FILE_SN, B.FILE_STRE_COURS, B.STRE_FILE_NM, B.ORIGNL_FILE_NM, B.FILE_EXTSN, B.FILE_CN, B.FILE_SIZE
FROM EMPLOYEE A LEFT OUTER JOIN ATCH_FILE_DETAIL B ON(A.E_EMPNO = B.ATCH_FILE_ID)
WHERE A.E_EMPNO = #{eEmpno}
</select>
==> 이걸로 정의되는 vo가 여기임
<resultMap type="employeeVO" id="employeeMap">
<result property="eEmpno" column="E_EMPNO"/>
<result property="eName" column="E_NAME"/>
.
.