improve efficiency of localObject for ROP
-----------------------------------------
Key: CAY-1234
URL: https://issues.apache.org/jira/browse/CAY-1234
Project: Cayenne
Issue Type: Improvement
Components: Cayenne Core Library
Reporter: Marcin Skladaniec
When used wisely prefetches can save significant amount of time in ROP. In
situation where the server and client are separated over large distance any
query takes some time, and in case of faulting few chained relationships we
have seen improvements measured in minutes!
Now the problem is that such query result is not always used in the same
context as it was fetched. Unfortunately when the localObject is used only the
object is copied, loosing all the already faulted related records. Can the
localObject accept one more parameter and allow deep merge of the localised
tree? Maybe the list of relationships to merge into the new copy can be passed
to the locaObject function as a array of String or something? Of course such
deep localObject would work only on PersistentState.COMMITTED objects
Illustrating example:
SelectQuery sq = new SelectQuery(Country.class, someExpression);
sq.addPrefetch("cities").setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
sq.addPrefetch("cities.galleries").setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
sq.addPrefetch("cities.galleries.paintings").setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
sq.addPrefetch("cities.galleries.paintings.artist").setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
//this executes in one SQL query, very fast
List<Country> countries = getCurrentContext().performQuery(sq);
//user is selecting a random city for editing. For safety reasons the object
has to be copied out of the original context.
City localisedCity = (City)
newContext.localObject(countries.get(3).getCities().get(4).getObjectId(), null);
now the localisedCity has no faulted relatioships. this means that to assemble
list of artists for the given city there going to be executed
- RelationshipQuery for galleries
- for each gallery RelatioshipQuery for paintings
- for each painting RelatiohshipQuery for artist
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.