-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Optional two/three levels one-to-many object relationship?
PostPosted: Thu Oct 08, 2009 1:58 am 
Newbie

Joined: Thu Oct 08, 2009 1:26 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.