Re: NamedQuery / SQLTemplate keyPath validation

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jun 10 2008 - 03:12:18 EDT

  • Next message: Andrus Adamchik: "Re: NamedQuery / SQLTemplate keyPath validation"

    Hi Lachlan,

    there is nothing there that would let you do that outside the context
    of query execution. One reason why we never pursued such functionality
    is because ... well, such context is needed:

    * you need a place to stick joins as you walk the expression path
    * you need a way to match bound variables against "?" in prepared
    statement (we don't do conversion from Date to String for instance, as
    there is no sane way to do that for all databases; we let JDBC driver
    handle bindings)
    * you need access to specific DbAdapter to generate correct SQL and
    correctly process bindings.

    The closest thing to what you describe is a procedure of translation
    of an EJBQL query (which is logically, but not semantically is a close
    analog of SelectQuery) to SQLTemplate. It is also done in the context
    of query execution, but with some effort it can probably be converted
    to a standalone SQLTemplate without execution.

    Andrus

    On Jun 10, 2008, at 9:26 AM, Lachlan Deck wrote:
    > Hi there,
    >
    > (question related to ROP)
    >
    > say I've got an Expression (whether complex or otherwise) and I want
    > to utilise that Expression in a NamedQuery or SQLTemplate... what's
    > the easiest way to transform the expression to an sql equivalent
    > string? (i.e., such that, e.g.,, boolean values are transformed from
    > say true to 1 (if using an int column), dates are formatted
    > appropriately etc, comparison operators are transformed (e.g., != to
    > <>) etc.
    >
    > I see that there's a QueryAssembler and QualifierTranslator etc, but
    > what I'm looking for, I guess, is a something like
    > expression.toSQLString(baseEntity).
    >
    > Any suggestions?
    >
    > Thanks.
    >
    > with regards,
    > --
    >
    > Lachlan Deck
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Jun 10 2008 - 03:12:52 EDT