|
Re: Fetch strategy tips [message #556071 is a reply to message #555623] |
Mon, 30 August 2010 17:31 |
|
Not sure I understand.
If you are only returning BigBoss why do you need to query Boss and Employee instead of just BigBoss?
Perhaps include your query code.
In terms on optimally loading of the objects you can use join fetching, or batch fetching (batch fetching would be more efficient for a 1-m). There is a query hint "eclipselink.batch".
If you just what to force the data to be fetched (for serialization), then you may consider the new LoadPolicy in EclipseLink 2.1.
James : Wiki : Book : Blog : Twitter
|
|
|
Re: Fetch strategy tips [message #556780 is a reply to message #555623] |
Thu, 02 September 2010 15:19 |
Matti Hansson Messages: 68 Registered: July 2009 |
Member |
|
|
Thank you for your reply and sorry for not being clear enough. It's kind of tough to explain.
The reason all three tiers are queried is that, in the usecase, the user is searching for a person using a name. In real life every type is a person, but in the model they do not inherit from a common Person class.
The answer is a list of BigBosses because it is they who are at the top of the hierarchy. The response does not only contain BigBosses, but the entire tree structure (with just the relevant nodes).
The relevant nodes are: for each person that has a matching name, get all its children and grandchildren, get its parent and grandparent, but do not get its siblings or its parent's siblings.
I'll try to explain using the example answer in the first post. "BigBoss 7: Marie" might actually have ten bosses, but after the query is run like so:
List<BigBoss> bigBosses = searchForPerson("Eric"); // bigBosses = {BB3:Eric, BB7:Marie}
BigBoss bigBossMarie = bigBosses.get(1);
List<Boss> myListOfBosses = bigBossMarie.getBosses(); myListOfBosses should only contain one element ("Tony") because that is the only node that is relevant to the search ("Eric"). On the other hand, if the search was for "Marie", myListOfBosses should contain all ten child nodes.
I can't find any information on the difference between join and batch fetching, but using one of those should let me skip steps 2, 4 and 6. Will try it out.
More comments and tips are welcome!
|
|
|
Powered by
FUDForum. Page generated in 0.02596 seconds