-->
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: modeling / metadata question
PostPosted: Tue Oct 14, 2003 11:12 am 
Newbie

Joined: Sun Oct 05, 2003 5:43 pm
Posts: 10
Location: Atlanta
Hello:

We are trying to model a set of classes that represent geographical locations. We have a set of GeoClasses that represent State,Countries, PostalCodes, and Cities. A Location class points to each of these classes using a many-to-one relationship, ie many locations will refer to a single Country record etc.

So Our location object looks something like
Location
{
address1,
address2,
address3,
geoCity,
geoState,
geoPostalCode,
geoCountry
}

The GeoPostalCode object is keyed by CountryCode (string) and (postal code) string.

We want to be able to create locations where only minimal information is nessisary, ie only a city name and country are given, or just perhaps a country.

The issue comes in on how to map the Postal Code and Country code. We want locations to not require a postal code but require a country.

So our latest attempt is as follows:

<many-to-one name="country" class="GeoCountry" column="country" not-null="true" >
</many-to-one>

<many-to-one name="postalCode" class="GeoPostalCode" insert="false" update="false" >
<column name="postal_code" />
<column name="country" />
</many-to-one>

This correctly allows us to generate the right SQL table, and insert locations with null postal codes, but with a correct Country.

Our Issue:

Upon trying to retrieve a location where the postalcode is null, Hibernate attempts to lazy load the postal code "null" using the country code in location record which results in an error since there is no record in the GeoPostalCode table that has a country of us with a code of null.


Any suggestions on how to configure the metadata to represent this situation where a compound key ie country and postal code share a common column ie country but where the country may be non-null, but postal code null.

Mike...


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.