- 爱易网页
-
ASP.NET教程
- NHibernate有关问题,集合列的读取
日期:2014-05-18 浏览次数:20516 次
NHibernate问题,集合列的读取。
目前有两个表,职员表和部门表。其中职员表中的部门ID是集合列,如何把当前职员的部门ID显示出来呢。
我的代码如下。
映射文件及XML文件:
职员表XML文件
<?xml version= "1.0 " encoding= "utf-8 " ?>
<hibernate-mapping xmlns= "urn:nhibernate-mapping-2.2 " namespace= "Domain.Admin " assembly= "Domain ">
<class name= "Staff " table= "PB_STAFF " proxy= "Staff ">
<cache usage= "read-write " />
<id name= "LoginId " column= "PB_LOGIN_ID " type= "String " length= "20 ">
<generator class= "assigned "/>
</id>
<property name= "Password " column= "PB_PASSWORD " type= "String " not-null= "true " length= "40 " />
<property name= "Code " column= "PB_CODE " type= "String " length= "40 " />
<property name= "Name " column= "PB_NAME " type= "String " not-null= "true " length= "40 " />
<property name= "Sex " column= "PB_SEX " type= "Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate " />
<property name= "Disabled " column= "PB_DISABLED " type= "Int32 " not-null= "true " />
<property name= "OrderId " column= "PB_ORDER_ID " type= "Int32 " not-null= "true " />
<many-to-one name= "Department " column= "PB_DEPARTMENT_ID " class= "Department " />
<set name= "Roles " table= "PB_STAFF_ROLE " lazy= "true ">
<cache usage= "read-write " />
<key column= "PB_LOGIN_ID " />
<many-to-many class= "Role " column= "PB_ROLE_ID " outer-join= "false " />
</set>
<set name= "ModuleRightsGrant " table= "PB_STAFF_MODULE_RIGHT_GRANT " lazy= "true ">
<cache usage= "read-write " />
<key column= "PB_LOGIN_ID " />
<many-to-many class= "ModuleRight " column= "PB_RIGHT_ID " outer-join= "false " />
</set>
<set name= "ModuleRightsDeny " table= "PB_STAFF_MODULE_RIGHT_DENY " lazy= "true ">