<resultMap id="boradResult" type="net.krespo.mybatis.Board">
<result property="boardid" column="BOARDID"/>
<result property="title" column="TITLE"/>
<result property="content" column="CONTENT"/>
<collection property="comments" column="BOARDID" javaType="java.util.ArrayList" ofType="net.krespo.mybatis.Comment" select="getCommentListById"/>
</resultMap>
<select id="getBoardById" resultMap="boardResult">
SELECT boardid, title, content FROM board WHERE boardid = #{boardid}
</select>
<select id="getCommentListById" resultType="net.krespo.mybatis.Comment">
SELECT commentid, boardid, writer, content FROM comment WHERE boardid = #{boardid
'DB > Mybatis' 카테고리의 다른 글
resultType에 int를 써도 Mapper에 Integer로 했다면 null 을 받을 수 있다. (0) | 2020.06.23 |
---|---|
시퀀스번호 로우 삭제시에도 순서대로 매겨지도록 만들기 (0) | 2020.02.14 |
쿼리스트링 값을 if문(test)에서 사용하는 방법 (0) | 2020.02.13 |
Mybatis에서 파라미터가 null면 where절 무시하고, 값이 있으면 where절을 적용하는 쿼리를 만들때 NullPointerException이 발생한다면? 꼭 점검해야할 것 (0) | 2020.01.30 |
ResultType과 ResultMap 차이 (0) | 2019.12.26 |
댓글