MyBatis映射文件6
之前說了由Employee找Department,這一節講一講由Department找Employee,顯然前者是多對一的關系,而後者是一對多的關系。
Department的JavaBean:
private Integer id; |
接口中的方法:
Department getDepByIdPlus(Integer id);
查詢的SQL語句:
<select id="getDepByIdPlus" resultMap="Dep"> |
接下來編寫resultMap,
collection:定義關聯集合類型的屬性的封裝規則
ofType:指定集合裏面的元素類型
<resultMap id= |
其實就是一個resultMap套著另外一個resultMap格式的collection
@Test |
MyBatis映射文件6