Re: Converting non-string and non-numeric expression parameters to EJBQL

From: Lachlan Deck (lachlan.dec..mail.com)
Date: Fri Aug 15 2008 - 02:46:33 EDT

  • Next message: Kevin Menard (JIRA): "[jira] Assigned: (CAY-1096) CayenneContext should support ThreadLocal operations"

    Hi Andrus,

    On 11/06/2008, at 5:37 PM, Andrus Adamchik wrote:

    > On Jun 11, 2008, at 3:26 AM, Lachlan Deck wrote:
    >
    >> Would that then be like this:
    >> EJBQLQuery query; // assume exists
    >> for (Map.Entry<String,Object> param : parametersCallback) {
    >> query.setParameter(param.getKey(), param.getValue());
    >> }
    >>
    >> Or would there still need to be special treatment given to dates
    >> and the like?
    >
    > Yes - as simple as your example above. Nothing special to do about
    > dates, etc.

    Is there a JIRA for this already?

    I've spent some time (as seen in the thread
    ObjEntity.translateToDbPath) attempting to come up with various
    methods to achieve agregate queries such as avg, max, min etc.
    Building the sql is reasonably trivial (and I've mucked around with
    trying to subclass the SelectTranslator, SelectAction, SelectQuery
    etc... and I keep getting snookered by default level access and
    such... besides which it's all overkill :)

    So I think I'm stuck without the above enhancement.

    >>> Note that this does not affect how you create your original
    >>> Expression objects.
    >>>
    >>> Does that sound reasonable?
    >>
    >> Sounds good, sure (so far as mapping between cayenne expressions
    >> and EJBQL). I wonder, however, if the parameters callback would be
    >> more generally useful. i.e., if it would make sense to place all
    >> values in there and not just the ones that can't be stringified.
    >
    > Possibly, especially for non-integer numerics, to avoid any possible
    > fuzziness.
    >
    >> Would it also make sense to have a Cayenne based CountQuery?
    >> e.g.,
    >> CountQuery count = new CountQuery(SelectQuery);
    >
    > We've had extensive discussions abut "utility" queries in the past.
    > I think we do need query-related utility classes/methods in some
    > form. I am not sure there should be a standalone query for each one
    > of them. Consider that there are also AVG, MAX, MIN, and other
    > things that a user might want to select. But more generally making
    > those types of queries easier to assemble and run is on the TODO list.

    Here's what I'm aiming for. I've got the below class. Perhaps a
    variation of this is what could go into Cayenne (with the right
    visitor/sqlaction stuff)?
    Or is it more about the column descriptors/meta data for a select query?

    int avg = new StatsQuery.Avg(SomeClass.class, "age"[,
    anExpression]).intResult(oc);
    int count = new StatsQuery.Count(SomeClass.class[,
    anExpression]).intResult(oc);
    int max = new StatsQuery.Max(SomeClass.class, "age"[,
    anExpression]).intResult(oc);
    int min = new StatsQuery.Min(SomeClass.class, "age"[,
    anExpression]).intResult(oc);
    int sum = new StatsQuery.Sum(SomeClass.class, "age"[,
    anExpression]).intResult(oc);

    with regards,

    --
    

    Lachlan Deck



    This archive was generated by hypermail 2.0.0 : Fri Aug 15 2008 - 02:47:11 EDT