Because one of our classes become too big with nearly 100 properties,
we must split it to 5 smaller classes (and inturn, 5 different tables)
to save performance. But now if I wanna access the base object from
part object, it is null. Here is the code:

namespace beans
{

    public class City
    {

        public CityResourcesData Resources
        {
            get;
            set;
        }
        public SomeEntity SomeProperty
        {

        }

    }
    public class CityResourcesData
    {
        private int _wood, _clay, _iron;

        #region Properties.Resources

        public virtual int Wood
        {
            get { return this._wood; }
            set
            {
                int max = this.Village.MaxResources;
                if (value > max)
                    this._wood = max;
                else if (value < 0)
                    this._wood = 0;
                else
                    this._wood = value;
            }
        }
        public virtual int Clay
        {
            get { return this._clay; }
            set
            {
                int max = this.Village.MaxResources;
                if (value > max)
                    this._clay = max;
                else if (value < 0)
                    this._clay = 0;
                else
                    this._clay = value;
            }
        }
        public virtual int Iron
        {
            get { return this._iron; }
            set
            {
                int max = this.Village.MaxResources;
                if (value > max)
                    this._iron = max;
                else if (value < 0)
                    this._iron = 0;
                else
                    this._iron = value;
            }
        }

        #endregion
        public virtual City City
        {
            get;
            set;
        }
    }
}



and the mapping:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

  <class name ="beans.City, beans" table="city_common" lazy="false">

    <id name="ID" column="id" type="Int32">
      <generator class="identity"/>
    </id>

    <property name="SomeProperty" column="some_column"/>
    <many-to-one name="Resources"  class="beans.CityResourcesData,
beans" column="id" fetch="select" lazy="proxy" />

  </class>

<class name ="beans.CityResourcesData, beans" table="city_resources"
lazy="true">
    <id name="ID" column="id" type="Int32">
      <generator class="foreign">
        <param name="property">City</param>
      </generator>
    </id>
    <property name="Gold" column="gold" />

    <one-to-one name="City" class="beans.City, beans"
constrained="true"/>

  </class>

Please help!!!
--~--~---------~--~----~------------~-------~--~----~
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