67,513
社区成员
发帖
与我相关
我的任务
分享
public class Book{
private int bookId;
private String title;
private authorId;
..相应的get和set
}
public class Book{
private int bookId;
private String title;
private Author author(区别在这);
..相应的get和set
}
<select id="selectBookById" parameterClass="java.lang.Integer" resultClass="Book">
select * from bs_book where bookId=#bookId#
</select>
<resultMap class="Book" id="BookMap">
<result property="bookId" column="bookId" />
<result property="title" column="title" />
<result property="author" column="authorId" select="selectAuthorById" />
<select id="selectBookById" parameterClass="java.lang.Integer" resultMap="BookMap">
select * from bs_book where bookId=#bookId#
</select>
<select id="selectAuthorById" parameterClass="java.lang.Integer" resultClass="Author">
select * from bs_author where authorId=#authorId#
</select>
</resultMap>
<result property="属性名(必须有get和set)" column="列名" />