Ok, I will simplify the mappings. Mol = PRP. I can get the correct
behavior on the organization side. The problem is on the Personnel
side where I want some collection for example IList<int> with the ids
of all organizations which the personnel is PRP (Mol).

------------------------------------------------------------------------------------------------------------------------------------------------
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
lazy="true">

  <class name="Test.IPersonnelEntity,Test.Core" table="`PERSONNEL`">
    <id name="Id" column="`PERSONNEL_ID`" type="Int32" unsaved-
value="0">
      <generator class="native"></generator>
    </id>
    <discriminator>
      <column name="`TYPE_CODE`" not-null="true" sql-type="varchar
(25)" />
    </discriminator>
    <version name="Version" column="`VERSION`" type="Int32" unsaved-
value="0" />

    <subclass
      name="Test.PersonnelEntity,Test.Domain"
      proxy="Test.IPersonnelEntity,Test.Core"
      discriminator-value="PersonnelEntity">

      <property name="Description"    column="`DESCR`" type="string"/>

      <many-to-one
         name="Org" class="Test.OrgEntity,Test.Domain"
column="`PERSONNEL_ORG_ID`" cascade="save-update" not-null="true"
lazy="proxy">
      </many-to-one>

      <many-to-one
        name="Warehouse" class="Test.WarehouseEntity,Test.Domain"
column="`PERSONNEL_WAREHOUSE_ID`" cascade="save-update" not-
null="true" lazy="proxy">
      </many-to-one>

      <!--<one-to-one name="OrgMol" class="Test,OrgEntity,Test.Domain"
constrained="true" property-ref="Mol" foreign-key="FK_OrgPersonnelMol"/
>-->

    </subclass>
  </class>
</hibernate-mapping>
------------------------------------------------------------------------------------------------------------------------------------------------
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
lazy="true">

  <class name="Test.IOrgEntity,Test.Core" table="`ORG`">
    <id name="Id" column="`ORG_ID`" type="Int32" unsaved-value="0">
      <generator class="native"></generator>
    </id>
    <discriminator><column name="`TYPE_CODE`" not-null="true" sql-
type="varchar(25)" /></discriminator>
    <version name="Version" column="`VERSION`" type="Int32" unsaved-
value="0" />

    <subclass
      name="Test.OrgEntity,Test.Domain"
      proxy="Test.OrgStructure.IOrgEntity,Test.Core"
      discriminator-value="OrgEntity">

      <property name="Name" column="`ORG_NAME`" type="string"/>

      <set name="_warehouses" table="`WAREHOUSE`" cascade="save-
update" access="field" generic="true" lazy="true" >
        <key column="`WAREHOUSE_ORG_ID`" foreign-
key="FK_OrgWarehouse" />
        <one-to-many class="Test.WarehouseEntity,Test.Domain"/>
      </set>

      <set name="_personnels" table="`PERSONNEL`" cascade="save-
update" access="field" generic="true" lazy="false" >
        <key column="`PERSONNEL_ORG_ID`" foreign-
key="FK_OrgPersonnel" />
        <one-to-many class="Test.PersonnelEntity,Test.Domain"/>
      </set>

      <many-to-one name="Mol"
             class="Test.PersonnelEntity,Test.Domain"
             column="`ORG_PERSONNEL_MOL`" cascade="save-update"
lazy="proxy" unique="true" not-null="false" />

    </subclass>
  </class>
</hibernate-mapping>
------------------------------------------------------------------------------------------------------------------------------------------------

On Jan 19, 11:37 am, Oskar Berggren <[email protected]> wrote:
> http://nhforge.org/doc/nh/en/index.html
>
> Is there anything specific you are having problems with? Have you
> gotten started? I don't think many people will be willing to simply
> write the entire mapping for you.
>
> Another suggestion, unrelated to the issue of mappings. I get the
> impression that an object of the Personnel class represents a single
> person. In that case personnel is a strange name, since it refers to
> the group of employed persons as a whole. I.e. Siemen's personnel is a
> group of about 400000 persons. I suggest Person or Employee instead.
>
> Also, the IList<object> seems strange. Why not specific types?
>
> /Oskar
>
> 2010/1/19 mynkow <[email protected]>:
>
> > Ok. I will try to explain what is the purpose here. I have an
> > Organization class, Warehouse class and a Personnel class.
>
> > 0) All rules for organization apply to warehouse.
> > 1) Each organization may have many personnels and each personnel may
> > have only one organization.
> > 2) Each organization may have (PRP)personal responsible person
> > (personnel). Each personnel can be personal responsible person to one
> > or many organizations and one or many warehouses.
>
> > The idea is that I want to have the id of a personnel in Organization
> > table. Also I want to say "Hey, this is Peter. Please tell me
> > Organization/warehouse objects which peter is PRP." The classes can be
> > changed, the rules are important.
>
> > public class Personnel
> > {
> >  public string Name{get;name;}
> >  public IList<object> OrgPRP{get;}
> >  public IList<object> WarehousePRP{get;}
> > }
>
> > public class Organization
> > {
> >  public string Name{ get; set; }
> >  public IList<Personnel> Personnels { get; }//there is a private
> > field here _personnels.
> >  public IList<Warehouse> Warehouses { get; }//there is a private
> > field here _warehouses.
> >  public Personnel PRP {get;set;}
> > }
>
> > public class Warehouse
> > {
> >  public string Name{ get; set; }
> >  public Personnel PRP {get;set;}
> > }
>
> > Best regards
> > mynkow
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/nhusers?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.


Reply via email to