Hi,
I am using Hibernate 2.1.7 and here are some of my persistent objects:
Company
User
PurchaseOrder
Address
.... and so on.
I want to create one-to-one mappings between:
Company and Address
User and Address
PurchaseOrder and Address
After reading page 37 of the Hibernate documentation, I successfully created this mapping between Company and Address (where the id value of Address comes from Company's id). But, as mentioned on page 37, the way to make this one-to-one mapping work is to make Address "aware" of Company, by having a property which points to the parent Company.
So here comes my problem:
Since I would like to have a one-to-one mapping between Address and the two other entity types (User and PurchaseOrder), how can I make Address "aware" of those three types simultaneously. I thought about creating a base class for all the parent objects of Address, so that Address would point to only one base type, but this does not seem to work.
Furthermore, does it really make a good design to have an entity like Address have to be "aware" of it's parent object?
Anybody have any ideas about this?
Thanks in advance,
Chris
|