Refer to http://groups.google.com/group/ebean/browse_thread/thread/5045ef2e88d91c1f
What I'd need is to define a Query with some base expressions, and
later on I'd like to add some expressions to the base, do something
with the query, and switch back to the base expression later on,
without the need to create the query from scratch.
I'd say it a little differently ... in that you need a "prototype" query
which has some existing expressions. You want to clone/copy the query
(creating a new query instance) that you can then add more expressions to
and then execute.
Note that I say "prototype" in that a Query is not threadsafe. You can't
have multiple threads executing the same query instance. So you create a
Query that's sole purpose is to act as a "prototype" or starting point...
which you can then copy/clone ... and then add extra expressions to the
You kind of get this with "Named Queries".
>> So is there an official way for this?
No, not yet - but making the query.copy() method public would be the
Possibly, although I think you would want to use expressionList.copy() in
that case (and that isn't public either).
Ultimately I see this as a request to make query.copy() public (so that a
query can act as a "prototype" to create other queries). I'll have another
look at the code and confirm that that will happen.