반응형
mybatis mapper를 사용할때 여러개의 테이블을 join하기 위해서
resultMap을 많이 사용한다.
<resultMap type="FeedDTO" id="FeedDTO">
<result column="user_code_no" property="userCodeNo"/>
<result column="feed_code" property="feedCode"/>
<result column="feed_text" property="feedtext"/>
<collection property="FollowDTO" resultMap="FollowDTO"/>
</resultMap>
이런 느낌으로!
근데 만약 resultMap으로 해줘야되는 테이블이 많다면?
하나하나 result column부터 해서 property까지 엄청 적어줘야한다..!
너무 힘들고 시작전부터 막막하다.
그러다 우연히 찾게 된 autoMapping!
<resultMap type="FeedDTO" id="FeedDTO" autoMapping="true">
</resultMap>
이렇게 autoMapping="true"를 넣어주면 자동 매핑된다..
너무나 유용하다 끝!
반응형
'공부 > SpringBoot & Spring' 카테고리의 다른 글
Mybatis TooManyResultsException 오류 (0) | 2022.06.15 |
---|---|
MyBatis 오류: Invalid bound statement (not found) (0) | 2022.06.15 |
thymeleaf Exception evaluating SpringEL expression 500 오류 (0) | 2022.06.14 |
AWS3 테스트 오류.. (0) | 2022.06.14 |
타임리프(thymeleaf) 객체 오류 (0) | 2022.06.14 |