Hi,
I was trying to model the following but got performance issue (might be incorrect modelling?). Please give me your professional advice.
There are three objects in the following relationship: 1. Country |-------- Region |-------- City 2. Region |-------- City 3. City
In sentense, a "City" could belong to a "Region" and must belong to a "Country". "Region" must belong to a "Country".
***** Mapping ***** <hibernate-mapping> <class name="my.model.Country" table="country"> <id name="id" column="id" unsaved-value="null"> <generator class="increment"/> </id> <property name="name" column="name" not-null="true"/> <set name="regions" lazy="true" cascade="all" inverse="true"> <key column="country_id"/> <one-to-many class="my.model.Region"/> </set> <set name="cities" lazy="true" cascade="all" inverse="true"> <key column="country_id"/> <one-to-many class="my.model.City"/> </set> </class>
<class name="my.model.Region" table="region"> <id name="id" column="id" unsaved-value="null"> <generator class="increment"/> </id> <property name="name" column="name"/> <many-to-one name="country" column="country_id" class="my.model.Country" /> </class>
<class name="my.model.City" table="city"> <id name="id" column="id" unsaved-value="null"> <generator class="increment"/> </id> <property name="name" column="name"/> <many-to-one name="country" column="country_id" class="my.model.Country" /> <many-to-one name="region" column="region_id" class="my.model.Region" /> </class> </hibernate-mapping> ******************
Issue: ===== I have setup three different info-update forms (e.g. change the "name") for each of these objects. I also pull out the list of countries for "Region" to select with, list of countries and regions for "City" to select with. The "Country" form loads up quite fast, but not for both "Region" and "City". Could any of you give me a hint on this? Is it a modelling problem?
Many thanks! stlei
|