|General design question on polymorphic collections and querying [message #536575]
||Fri, 28 May 2010 17:28
| Brett Bergquist
Registered: July 2009
I have something similar to the following class hierarchy|
| | |
ConfigurationSet9145E ConfigurationSet9161 ConfigurationSetXXX
| | |
ConfigurationBundle9145E ConfigurationBundle9161 ConfigurationBundleXXX
| | |
AccountBundle9161 HostsBundle9161 IpConfigurationBundle9161
etc where XXX is other ConfigurationSet or ConfigurationBundle subordinate classes and within for each subordinate
ConfigurationBundle class are subordinate classes that specific to a type of information being stored. Basically a ConfigurationSet
is a class that maintains information about the configuration of a device including the time, change date, etc. and the specific
configuration of the device is maintained by ConfigurationBundle subordinate classes. So there is a specific subclass of
ConfigurationSet for each type of device which maintains a collection of ConfigurationBundle subordinate class instances specific to
the type of device.
From this, I am able to do some things at a generic level such as report on the configuration changes to a device, when it was
done, and who did it and also able to determine differences between device configurations.
The above screams out for using Generics in that both ConfigurationSet and ConfigurationBundle would be generic over the type of
device. Currently I have the collection of ConfigurationBundles located within the ConfigurationSet and do casting, but that is not
the main problem.
The problem that I am having is that sometimes I know that I have a 9161 device and I want to access the ConfigurationBundle's of
this device. Currently the query is done against the ConfigurationSet class and because this is where the ConfigurationBundle's
reside and there could and is a mix of subordinate instances, the query is polymorphic. With a large number of devices (ie, many
subordinate ConfigurationSet classes and many subordinate ConfigurationBundle classes), the query is quite complex and does not
perform the best.
In this case, however, I know which specific subclass instances I am interested in so the query could be greatly optimized. But I
know of know way right now in JPA 1.0 to convey this information but I was wondering if in Eclipselink 1.x if there is a way to
optimize this type of query. Basically if I could specify the discriminator or specify the type of class that should be retrieved,
the database query could be made more efficient.
Any ideas on how this could be done?
Thanks for any feedback.
Powered by FUDForum
. Page generated in 0.17383 seconds