C# NHibernate连接和投影属性

C# NHibernate连接和投影属性,c#,nhibernate,linq-to-nhibernate,C#,Nhibernate,Linq To Nhibernate,我有简单的情况(如图中所示)和简单的SQL查询 SELECT M.Name, A.Name, B.Name FROM Master M LEFT JOIN DetailA A ON M.DescA = A.Id LEFT JOIN DetailB B ON M.DescB = B.Id <property name="FirstName" column="FIRST_NAME" type="st

我有简单的情况(如图中所示)和简单的SQL查询

SELECT  M.Name, 
          A.Name, 
          B.Name 
FROM Master M       LEFT JOIN DetailA A
ON M.DescA = A.Id   LEFT JOIN DetailB B
ON M.DescB = B.Id
<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
如何使用CriteriaAPI在nHibernate中实现相同的效果

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
我有这样的想法:

public class Employee : ClassBase, IContactData
{
    public virtual string FirstName { get; set; }
    public virtual string MiddleName { get; set; }
    public virtual string LastName { get; set; }
    public virtual string NickName { get; set; }
    public virtual string Login { get; set; }
    public virtual string Password { get; set; }
    public virtual string ContactPerson { get; set; }
    public virtual string PESEL { get; set; }
    public virtual string IdentificationNo { get; set; }
    public virtual string NIP { get; set; }
    public virtual string Description { get; set; }
    public virtual string Profession { get; set; }
    public virtual byte[] Photo { get; set; }
    public virtual DateTime? BirthDate { get; set; }
    public virtual Boolean SpecialUser { get; set; }
    public virtual Boolean Sex { get; set; }
    public virtual Item Gender { get; set; }
    public virtual Item Position { get; set; }
    public virtual Item Status { get; set; }
    public virtual Item Nation { get; set; }
    public virtual Item Education { get; set; }
    public virtual Item JobType { get; set; }
    public virtual ISet<Address> Addresses { get; set; }
}

public class Item : ClassBase
{

    public virtual int ItemCode { get; set; }
    public virtual int DictCode{ get; set;}
    public virtual string Description{ get; set;}

    public override string ToString()
    {
        return Description;
    }
}

public class Address : ClassBase
{
    public virtual string Description { get; set; }
    public virtual string District { get; set; }
    public virtual string Community { get; set; }
    public virtual string City { get; set; }
    public virtual string Street { get; set; }
    public virtual string PostalCode { get; set; }
    public virtual string HouseNo { get; set; }
    public virtual string FlatNo { get; set; }
    public virtual Boolean Official { get; set; }
    public virtual Item Country { get; set; }
    public virtual Item Region { get; set; }
}
<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
public类雇员:ClassBase,IContactData
{
公共虚拟字符串FirstName{get;set;}
公共虚拟字符串MiddleName{get;set;}
公共虚拟字符串LastName{get;set;}
公共虚拟字符串昵称{get;set;}
公共虚拟字符串登录{get;set;}
公共虚拟字符串密码{get;set;}
公共虚拟字符串ContactPerson{get;set;}
公共虚拟字符串PESEL{get;set;}
公共虚拟字符串标识No{get;set;}
公共虚拟字符串NIP{get;set;}
公共虚拟字符串描述{get;set;}
公共虚拟字符串职业{get;set;}
公共虚拟字节[]Photo{get;set;}
公共虚拟日期时间?生日{get;set;}
公共虚拟布尔特殊函数{get;set;}
公共虚拟布尔性{get;set;}
公共虚拟项性别{get;set;}
公共虚拟项位置{get;set;}
公共虚拟项状态{get;set;}
公共虚拟项{get;set;}
公共虚拟项教育{get;set;}
公共虚拟项作业类型{get;set;}
公共虚拟ISet地址{get;set;}
}
公共类项:ClassBase
{
公共虚拟int ItemCode{get;set;}
公共虚拟代码{get;set;}
公共虚拟字符串描述{get;set;}
公共重写字符串ToString()
{
返回说明;
}
}
公共类地址:ClassBase
{
公共虚拟字符串描述{get;set;}
公共虚拟字符串区域{get;set;}
公共虚拟字符串社区{get;set;}
公共虚拟字符串City{get;set;}
公共虚拟字符串Street{get;set;}
公共虚拟字符串PostalCode{get;set;}
公共虚拟字符串HouseNo{get;set;}
公共虚拟字符串FlatNo{get;set;}
公共虚拟布尔官方{get;set;}
公共虚拟项国家{get;set;}
公共虚拟项区域{get;set;}
}
映射:

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
我需要:

<property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
<property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
<property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
<property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
<property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
<property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
<property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
<property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
<property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
<property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
<property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
<property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
<property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
<property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
<property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
<property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>

<many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />

<set name="Addresses" table="TBL_ADDRESS" generic="true">
  <key column="FK_EMPLOYEE" />
  <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
</set>
<property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
<property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
<property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
<version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
<property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
<property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
<property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
<property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
<property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
<property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
<property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
<property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
<property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>

<many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
<many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
  • 将数据检索到我的网格控件
    • -名字,
      -姓氏,
      -NIP,
      -位置说明,
      -教育。说明,
      -JobType.Description,
      -Country.Description-来自地址,其中Address.Official为true,
      -街道-从地址。官方为真的地址开始,
      -HouseNo-来自地址。官方为真的地址,
      -FlatNo-来自地址。官方为真的地址。
  • 将数据检索到另一个网格控件
    • -名字,
      -姓氏,
      -NIP,
      -位置说明,
      -教育。说明,
      -作业类型。说明。
    而最重要的是思考。我只想使用一条SELECT语句来实现这一点。 现在,对于第1点,我使用NamedSQLQuery,一切正常,但对于最简单的情况,我希望使用CriteriaAPI

    <property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
    <property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
    <property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
    <property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
    <property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
    <property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
    <property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
    <property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
    <property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
    <property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
    <property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
    <property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
    <property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
    <property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
    <property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
    <property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>
    
    <many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    
    <set name="Addresses" table="TBL_ADDRESS" generic="true">
      <key column="FK_EMPLOYEE" />
      <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
    </set>
    
    <property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
    <property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
    <property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
    
    <version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
    <property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
    <property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
    <property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
    <property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
    <property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
    <property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
    <property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
    <property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
    <property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>
    
    <many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
    
    同样对于第1点和第2点,我有DTO类,我将查询结果转换为这个类

    <property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
    <property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
    <property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
    <property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
    <property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
    <property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
    <property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
    <property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
    <property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
    <property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
    <property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
    <property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
    <property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
    <property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
    <property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
    <property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>
    
    <many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    
    <set name="Addresses" table="TBL_ADDRESS" generic="true">
      <key column="FK_EMPLOYEE" />
      <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
    </set>
    
    <property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
    <property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
    <property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
    
    <version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
    <property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
    <property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
    <property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
    <property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
    <property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
    <property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
    <property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
    <property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
    <property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>
    
    <many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
    

    我可以通过GetAllEmployees()实现这一点,但许多属性都是延迟加载的,这样做会在应用程序和数据库之间产生巨大的流量。我可以将这些属性更改为“快速加载”,但我认为有太多的数据需要检索,而我并不需要这些数据。

    对于这种情况,我的建议是,如果您希望显示包含多个实体数据的网格,只需创建一个sql视图并将其映射到NH即可

    <property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
    <property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
    <property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
    <property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
    <property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
    <property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
    <property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
    <property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
    <property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
    <property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
    <property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
    <property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
    <property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
    <property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
    <property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
    <property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>
    
    <many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    
    <set name="Addresses" table="TBL_ADDRESS" generic="true">
      <key column="FK_EMPLOYEE" />
      <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
    </set>
    
    <property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
    <property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
    <property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
    
    <version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
    <property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
    <property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
    <property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
    <property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
    <property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
    <property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
    <property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
    <property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
    <property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>
    
    <many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
    
    从长远来看,你会更快乐

    我找到了解决方案:)

    <property name="FirstName"        column="FIRST_NAME"         type="string"   length="50"    not-null="true"/>
    <property name="MiddleName"       column="MIDDLE_NAME"        type="string"   length="50"    not-null="false"/>
    <property name="LastName"         column="LAST_NAME"          type="string"   length="50"    not-null="true"/>
    <property name="NickName"         column="NICKNAME"           type="string"   length="50"    not-null="false"/>
    <property name="Login"            column="LOGIN"              type="string"   length="30"    not-null="false"/>
    <property name="Password"         column="PASSWORD"           type="string"   length="100"   not-null="false"/>
    <property name="ContactPerson"    column="CONTACT_PERSON"     type="string"   length="250"   not-null="false"/>
    <property name="PESEL"            column="PESEL"              type="string"   length="11"    not-null="false"/>
    <property name="IdentificationNo" column="IDENTIFICATION_NO"  type="string"   length="12"    not-null="false"/>
    <property name="NIP"              column="NIP"                type="string"   length="11"    not-null="false"/>
    <property name="Description"      column="DESCRIPTION"        type="string"   length="1000"  not-null="false"/>
    <property name="Profession"       column="PROFESSION"         type="string"   length="150"   not-null="false"/>
    <property name="BirthDate"        column="BIRTH_DATE"         type="DateTime"                not-null="false"/>
    <property name="Photo"            column="PHOTO"              type="BinaryBlob"              not-null="false"/>
    <property name="Sex"              column="SEX"                type="Boolean"                 not-null="false"/>
    <property name="SpecialUser"      column="SPECIAL_USER"       type="Boolean"                 not-null="false"/>
    
    <many-to-one name="Gender"        column="DIC_GENDER"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Position"      column="DIC_POSITION"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Status"        column="DIC_STATUS"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Nation"        column="DIC_NATION"         not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Education"     column="DIC_EDUCATION"      not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="JobType"       column="DIC_JOB_TYPE"       not-null="false" class="DomainModel.ERP.Item,DomainModel" />
    
    <set name="Addresses" table="TBL_ADDRESS" generic="true">
      <key column="FK_EMPLOYEE" />
      <one-to-many class="DomainModel.ERP.HRM.Address,DomainModel"/>
    </set>
    
    <property name="ItemCode"         column="ITEM_CODE"          type="integer"  not-null="true"/>
    <property name="DictCode"         column="TABLE_CODE"         type="integer"  not-null="true"/>
    <property name="Description"      column="NAME"               type="string"   length="200"   not-null="true"/>
    
    <version  name="Version"      column="VERSION"       type="integer"  unsaved-value="0"/>
    <property name="Description"  column="DESCRIPTION"   type="string"   length="1000"  not-null="false"/>
    <property name="District"     column="DISTRICT"      type="string"   length="15"    not-null="false"/>
    <property name="Community"    column="COMMUNITY"     type="string"   length="150"   not-null="false"/>
    <property name="City"         column="CITY"          type="string"   length="150"   not-null="true"/>
    <property name="Street"       column="STREET"        type="string"   length="150"   not-null="true"/>
    <property name="PostalCode"   column="POSTAL_CODE"   type="string"   length="10"    not-null="false"/>
    <property name="HouseNo"      column="HOUSENO"       type="string"   length="20"    not-null="true"/>
    <property name="FlatNo"       column="FLATNO"        type="string"   length="20"    not-null="false"/>
    <property name="Official"     column="IS_OFFICIAL"   type="Boolean"                 not-null="true"/>
    
    <many-to-one name="Country"           column="DIC_COUNTRY"      not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
    <many-to-one name="Region"            column="DIC_REGION"       not-null="false"  class="DomainModel.ERP.Item,DomainModel" />
    
    var master=DetachedCriteria.For()
    .CreateAlias(“DetailA”、“detA”、JoinType.LeftOuterJoin)
    .CreateAlias(“DetailB”、“detB”、JoinType.LeftOuterJoin)
    .SetProjection
    (
    投影。投影列表()
    .Add(Projections.Property(“Id”),“Id”)
    .Add(Projections.Property(“名称”),“MasterName”)
    .Add(Projections.Property(“detA.Name”),“detainame”)
    .Add(Projections.Property(“detB.Name”),“DetailBName”)
    )
    .SetResultTransformer(Transformers.AliasToBean(typeof(MasterDTO)));
    班主任
    {
    公共虚拟整数Id{get;set;}
    公共虚拟字符串主名称{get;set;}
    公共虚拟字符串详细信息名称{get;set;}
    公共虚拟字符串DetailBName{get;set;}
    公共主管
    {}
    public MasterDTO(int-id、string-mastername、string-detailaname、string-detailbname)
    {
    Id=Id;
    MasterName=MasterName;
    DetailAName=DetailAName;
    DetailBName=DetailBName;
    }
    }
    
    您需要在映射中包含一些详细信息才能给出任何类型的答案您真的只想得到名称吗?通常在使用ORM时,您可以获得整个对象。这种情况下可以轻松处理分页场景吗?