Re: SQL Template & Thread Safety

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Oct 05 2004 - 07:28:44 EDT

  • Next message: Gentry, Michael: "RE: Unique fields"

    Gary,

    Sorry if I wasn't clear. Cayenne provides
    ParameterizedQuery.createQuery() method. It does the right thing. This
    is what I was referring to.

    Andrus

    On Oct 5, 2004, at 12:37 AM, Gary Jarrel wrote:

    > Provided API? Cayenne provided or the Object.clone() method? Couldn't
    > the
    > object.clone method could run into problems with the shallow copy?
    >
    > Thanks!
    >
    > - Gary
    >
    > -----Original Message-----
    > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > Sent: Tuesday, October 05, 2004 12:41 PM
    > To: cayenne-use..bjectstyle.org
    > Subject: Re: SQL Template & Thread Safety
    >
    >
    > 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 : Tue Oct 05 2004 - 07:28:50 EDT