Last active
March 31, 2018 15:07
-
-
Save rararamorio/6a480a6984b957fdc7edeee9da70f957 to your computer and use it in GitHub Desktop.
categoryが取得できない
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<!DOCTYPE mapper | |
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
<mapper namespace="person"> | |
<resultMap id="personMap" type="jp.sample.mybatis.entity.Person"> | |
<id property="personId" column="person_id" /> | |
<result property="personId" column="person_id" /> | |
<result property="name" column="name" /> | |
<collection property="books" columnPrefix="b_" resultMap="BookMap" /> | |
</resultMap> | |
<resultMap id="BookMap" type="jp.sample.mybatis.entity.Book"> | |
<id property="bookId" column="book_id" /> | |
<result property="bookId" column="book_id" /> | |
<result property="name" column="name" /> | |
<association property="category" columnPrefix="c_" resultMap="CategoryMap" /> | |
</resultMap> | |
<resultMap id="CategoryMap" type="jp.sample.mybatis.entity.Category"> | |
<id property="categoryId" column="category_id" /> | |
<result property="categoryId" column="category_id" /> | |
<result property="name" column="name" /> | |
</resultMap> | |
<select id="selectByPersonId" resultMap="personMap"> | |
SELECT | |
p.person_id | |
, p.name | |
, b.book_id as b_book_id | |
, b.name as b_name | |
, c.category_id as c_category_id | |
, c.name as c_name | |
FROM | |
person p | |
INNER JOIN person_book pb USING(person_id) | |
INNER JOIN book b USING(book_id) | |
INNER JOIN category c USING(category_id) | |
WHERE | |
p.person_id=#{person_id} | |
</select> | |
</mapper> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment