mybatis中一对一关系映射
一对一关系中普通的配置方式 一.多表连接查询语句: <select id="selectStudentWithAddress" parameterType="int" resultMap="StudentWithAddressResult"> select s.stud_id, s.name, s.email,s.dob,s.phone, a.addr_id, a.street, a.city, a.state, a.zip,a.country from students s left outer join addresses a on s.addr_id=a.addr_id where stud_id=#{id} </select> 1. 把所有的查询结果,在一个resultMap中映射 <resultMap type="Student" id="StudentWithAddressResult"> <id property="studId" column="stud_id" /> <result property="name" column="name" /> <result property="email" column="email" /> <result property="phone" column="phone" /> <!--adderss是Student的内置对象