双向一对多取值问题
Department
private int id;
private String dt_name;
private Date dt_createTime;
private int dt_amount;
private String dt_context;
private Set<Employee> employees;
Employee
private int id;id为外键是department的主键
***hbm.xml
<id name="id" length="4"></id>
<property name="dt_name"></property>
<property name="dt_createTime"></property>
<property name="dt_amount"></property>
<property name="dt_context"></property>
<set name="employees" inverse="true" >
<key column="id"></key>
<one-to-many class="Employee" />
</set>
Employee.hbm.xml中配置
<many-to-one name="department" column="id" not-null="true" lazy="false"/>
我想在jsp页面中取得对应部门中的员工人数,怎么拿?
谢谢高手指教!!!
------解决方案--------------------
department.getEmployees().size()