On Oct 4, 2004, at 5:14 PM, Mike Kienenberger wrote:
> Gary Jarrel <garyjarre..rownbilljarrel.com.au> wrote:
>> I had a quick browse of the Cayenne code
>> and the call to getQuery seems to return a singleton instance of
>> Query/SqlTemplate.
>
> Seems like a bug to me. I'd open a issue in the bug tracker.
>
> Maybe submit a patch too :)
No, this is not a bug. It is a feature ;-)... All types of queries
stored in the model should be viewed as prototypes of the final queries
(as in "prototype pattern"), and thus all of them implement
ParameterizedQuery interface -
http://objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/
query/ParameterizedQuery.html. An implementation of
"DataContext.performQuery(String,Map,boolean)" illustrates this point,
and BTW can be used to run stored queries in a thread-safe manner,
saving a few lines of code.
In other words - if your stored query has no parameters (and requires
no further customizations in the code), you can run it directly,
otherwise it has to be cloned using provided API.
Andrus
This archive was generated by hypermail 2.0.0 : Mon Oct 04 2004 - 22:40:50 EDT