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

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jun 10 2008 - 08:28:51 EDT

  • Next message: Michael Gentry: "Re: Apache Board Report (June)"

    Hi Lachlan, sorry for confusion on my part...

    As it turned out, there are actually 3 separate issues

    * Serialization when running EJBQL with ROP (CAY-1072 - fixed)
    * Converting lists of values to EJBQL Strings (CAY-1073 - fixed)
    * Converting non-string and non-numeric expression parameters to EJBQL
    (no Jira yet, I will pen one soon...).

    In regards to the last one, per my second comment on CAY-1072, I
    totally agree with you that we need to handle this case. However we
    can't convert those to Strings. This is just not possible because (a)
    EJBQL syntax only supports literals for Strings, numerics, enums and
    booleans; (b) Cayenne fundamentally would not deal with things like
    Date[Time] to String and back conversion, as this is the functionality
    of the JDBC layer.

    So the solution has to be elsewhere. What I was proposing (maybe there
    is a better one?) is this:

       Expression.toEJBQL(String rootId, Map parametersCallback);

    Expression object would stick any parameters generated internally into
    'parametersCallback' map. So that later you could pass it to
    EJBQLQuery. Note that this does not affect how you create your
    original Expression objects.

    Does that sound reasonable?

    Andrus

    On Jun 10, 2008, at 3:08 PM, Lachlan Deck (JIRA) wrote:

    >
    > [ https://issues.apache.org/cayenne/browse/CAY-1073?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12950
    > #action_12950 ]
    >
    > Lachlan Deck commented on CAY-1073:
    > -----------------------------------
    >
    > Comments from CAY-1072: Andrus wrote:
    > ----
    > Yes, converting dates to Strings are a no-go. I don't see us being
    > able to fix that on the short run. Could you try a parameterized
    > expression instead (using $param instead of date literals).
    > On the other hand, we need some way to handle dates or other
    > parameters that can't be converted into literals... I guess one way
    > is to generate "synthetic" parameters and collect values in a map
    > passed as an argument.
    > ----
    >
    > The problem is that I can't use parameter based expressions as they
    > are constructed elsewhere (as instances of Expression) and re-used
    > in various places (including in-memory).
    >
    > Is it not possible to re-use whatever code in Cayenne already
    > converts such values (depending on the associated DbAttribute, for
    > example)?



    This archive was generated by hypermail 2.0.0 : Tue Jun 10 2008 - 08:29:24 EDT