Spring _MyBatis _resultMap
쿼리문 자체에서 AS 를 이용해 컬럼명 AS 필드명 과 같이 이름을 일치시키는 방법
<select id = "getEmpList" resultType="com.spring.myapp.hr.vo.EemployeeVO">
EMPLOYEE_ID as employeeId,
FIRST_NAME as firstName,
LAST_NAME as lastName,
EMAIL as email,
PHONE_NUMBER as phoneNumber,
HIRE_DATE as hireDate,
JOB_ID as jobId,
SALARY as salary,
COMMISSION_PCT as commissionPct,
MANAGER_ID as mangerId,
DEPARTMENT_ID as departmentId
FROM EMPLOYEES
</select>
xml 파일 내부에서 resultMap 태그 사용
<resultMap id = "empMap" type = "com.spring.myapp.hr.vo.EemployeeVO">
<result column="EMPLOYEE_ID" property="employeeId"/>
<result column="FIRST_NAME" property="firstName"/>
<result column="LAST_NAME" property="lastName"/>
<result column="EMAIL" property="email"/>
<result column="PHONE_NUMBER" property="phoneNumber"/>
<result column="HIRE_DATE" property="hireDate"/>
<result column="JOB_ID" property="jobId"/>
<result column="SALARY" property="salary"/>
<result column="COMMISSION_PCT" property="commissionPct"/>
<result column="MANAGER_ID" property="mangerId"/>
<result column="DEPARTMENT_ID" property="departmentId"/>
</resultMap>
<select id = "getEmpList" resultMap="empMap">
SELECT * FROM EMPLOYEES
<if test = "empid != null">
WHERE employee_id = #{empid}
</if>
</select>
Author And Source
이 문제에 관하여(Spring _MyBatis _resultMap), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@jominjun94/MyBatis-resultMap저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)