Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » General design question on polymorphic collections and querying
General design question on polymorphic collections and querying [message #536575] Fri, 28 May 2010 17:28 Go to next message
Brett Bergquist is currently offline Brett BergquistFriend
Messages: 31
Registered: July 2009
Member
I have something similar to the following class hierarchy

ConfigurationSet
|
|
-----+--------------+-------------------------
| | |
ConfigurationSet9145E ConfigurationSet9161 ConfigurationSetXXX


ConfigurationBundle
|
|
-----+-----------------+----------------------------
| | |
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.

Brett
Re: General design question on polymorphic collections and querying [message #536971 is a reply to message #536575] Mon, 31 May 2010 17:58 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Possibly, you could define the mapping in each subclass instead of the root.

You may also be able to use a VariableOneToOneMapping in EclipseLink to store an indicator for the relationship.

Otherwise, using the inheritance query may be the best solution, other than changing your model.



James : Wiki : Book : Blog : Twitter
Re: General design question on polymorphic collections and querying [message #537425 is a reply to message #536971] Wed, 02 June 2010 12:18 Go to previous message
Brett Bergquist is currently offline Brett BergquistFriend
Messages: 31
Registered: July 2009
Member
James, I want to thank you for taking the time to respond. This is really appreciated.

James wrote:
> Possibly, you could define the mapping in each subclass instead of the
> root.

This is what I probably will do.

>
> You may also be able to use a VariableOneToOneMapping in EclipseLink to
> store an indicator for the relationship.
>
> Otherwise, using the inheritance query may be the best solution, other
> than changing your model.
>
>
Previous Topic:Can eclipselink use better table names in its generated sql?
Next Topic:bizarre DATE adjustment during binding
Goto Forum:
  


Current Time: Thu Apr 25 03:41:38 GMT 2024

Powered by FUDForum. Page generated in 0.02867 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top