refid(reference id)는 반복되는 쿼리를 미리 작성해 놓고 재활용 할 수 있게 해준다.
작성 예시
<mapper>
<sql id="a">
SELECT *
FROM TABLE
</sql>
<sql id="b">
SELECT *
FROM TABLE
WHERE ${param1}
</sql>
<select id="getListA" resultType="hashmap">
<include refid="a" />
WHERE filed = #{value}
</select>
<select id="getListB" resultType="hashmap">
<include refid="b">
<property name="param1" value="value">
</include>
WHERE filed = #{value}
</select>
</mapper>
쿼리 실행 결과
1
2
3
|
SELECT *
FROM TABLE
WHERE filed = #{value}
|
'DEV' 카테고리의 다른 글
[mybatis] mybatis에서 selectKey 사용법 (0) | 2022.05.13 |
---|---|
[리눅스] 주요 명령어 (0) | 2021.07.27 |
[이클립스] 프로젝트별 Workspace name 지정 (0) | 2021.06.10 |
[eXbuilder6] Common button, title-bar button (0) | 2021.02.22 |
[eXbulider6] 네임스페이스 명명 메모 (0) | 2021.02.22 |