<resultMap id=”get-product-result” class=”com.ibatis.example.Product”>
<result property=”id” column=”PRD_ID”/>
<result property=”description” column=”PRD_DESCRIPTION”/>
<result property=”category.id” column=”CAT_ID” />
<result property=”category.description” column=”CAT_DESCRIPTION” />
</resultMap>
<statement id=”getProduct” parameterClass=”int” resultMap=”get-product-result”>
select * from PRODUCT, CATEGORY where PRD_CAT_ID=CAT_ID and PRD_ID = #value#
</statement>
public class Product{
private String id;
private String description;
private Category category;
...
}
여기서 문제가 있다.
바로 Category에 대한 새로운 생성자를 만들어 주지 않았기 때문이다.
public class Product{
private String id;
private String description;
private Category category = new Category();
...
}
이렇게 되어야한다.
내 2시간..