department与employee是一对多关系。
set
<set name="emps" inverse="true">
<key column="depart_id"/>
<one-to-many class="Employee" />
</set>
list,关键在于有一定顺序:
<list name="emps">
<key column="depart_id" />
<list-index column="order_col" />
<one-to-many class="Employee" />
</list>
所以需要配置<list-index column="order_col" />
map: Map<Strig,Employee> emps;
<map name="emps">
<key column="depart_id" />
<map-key type="string" column="name"/>
<one-to-many class="Employee" />
</map>
bag:想用list又不需要保证顺序
<bag name="emps">
<key column="depart_id" />
<one-to-many class="Employee" />
</bag>