I have the following scenario and have been unable to resolve the underlying 
issues by reading either the manual or the faq.

<!-- The class names are contrived but the underlying relationships accurately
reflect the problem I am trying to address -->

I have two inheritance hierarchies. eg. Customer is a base class and 
InternalCustomer and ExternalCustomer are derived classes. Similarly
Location is a base class whereas IndustrialLocation and CommercialLocation
are derived classes.

We have chosen to implement the table-per-concreteclass strategy (ie. each 
table has columns for the base class as well). So in a scenario where say an 
Invoice needs a reference to a customer, I have set up an "<any>" relationship 
from invoice to customer, by using customerType and customerId columns in the 
invoice table. 

However we need to setup a "one-to-many" relationship between a customer and a 
location (ie. polymorphic both ways with tables created for leaf classes only).
This can be easily done at a table level by creating "customerType" 
and "customerId" columns in each of the location tables. I have also been able 
to be able to reference the customer object from a location object by using 
the "<any>" tag in the hbms of the location classes. I am unable to decide how 
to implement the relationship from customer to location using hibernate. 

I am looking for the ability to implement the "Set getLocations()" method in 
Customer.

The following option does come to my mind (not certain if it is necessarily 
implementable)

a. Implement getIndustrialLocations() and getCommercialLocations() seperately. 
This requires my customer class to not be able to deal with Locations 
polymorphically. Moreover it will require me to modify the source as and when I 
add new Derived classes for Location.   

I am however struggling for a better solution. Any suggestions will be welcome.

Thanks
Dhananjay


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to