This is an follow-up to a question I asked previously. **** To re-cap In the context of a web-app (i.e. you don't know who your users are, or what kind of absurd 'give me everything and let me sort' actions they might take), I need to be able to support real-time sorting of perhaps large result sets.
So the recommendation was to prefer the DBMS sort over Cayenne in-memory sort (which would fault all of the result-set dataobjects). I can sort of understand the rational that it is better to re-submit the query with a new sort-by request, as this will ultimately be more memory efficient. Requirements Also, I have some fairly advanced pre-built search methods that support often-used searches. It is the results of these searches that may be sorted several times and in several different ways by the user. **** Interesting Side-effect In order to implement the 'let the DBMS do it' pattern, I created a SearchFactory class that stores the pre-built Cayenne SelectQuery, so that I can resubmit it to Cayenne with a user chosen sort-by specification. Here are some questions: 1. I have to store the SelectQuery in a custom session object. This *seems* like a good idea but since I have never done this, I was wondering if storing a query might not be memory-efficient. i.e. does this object hold on to any result sets? 2. This pattern essentially makes some of the very cool Cayenne ORM features useless. i.e. I can no longer simply request the Vendor's associated product list by doing a Cayenne 'vendor.getProductList()', since I can't store the query (as I need to do in order to re-submit the query with a new Ordering object). This is all working, but since I have to make a *lot* of changes in my code, I want to make sure it is the best solution with Cayenne. Does all of this sound reasonable, or am I missing some simpler way of implementing this solution? Thanks Joe
