81,114
社区成员
发帖
与我相关
我的任务
分享
<?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="Subject.mapper">
<select id="selectSubject" parameterType="int" resultType="com.demo.bean.Subject" resultMap="subjectMap">
select * from _subject where _id=#{id};
</select>
<resultMap type="com.demo.bean.Subject" id="subjectMap">
<id property="id" column="_id"/>
<result property="subName" column="sub_name"/>
<collection property="students" column="_subject" javaType="java.util.ArrayList" ofType="com.demo.bean.Student" select="selectStudents"></collection>
</resultMap>
<select id="selectStudents" resultType="com.demo.bean.Student" parameterType="int">
select _id as id ,_name as name ,_sex as sex
</select>
</mapper>