Re: NamedQuery / SQLTemplate keyPath validation

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jun 10 2008 - 04:02:33 EDT

  • Next message: Lachlan Deck: "Re: NamedQuery / SQLTemplate keyPath validation"

    Unlike SQLTemplate, EJBQL operates in object terms, abstracted from
    SQL (this is why I said earlier that it is similar to SelectQuery). So
    it is free from the constraints that I mentioned and you can do
    something like this:

       String ejbql = "SELECT count(a) FROM Artist a WHERE " +
    expression.toEJBQLString("a");

    Andrus

    On Jun 10, 2008, at 10:52 AM, Lachlan Deck wrote:

    > Hi Andrus,
    >
    > On 10/06/2008, at 5:37 PM, Andrus Adamchik wrote:
    >
    >> On Jun 10, 2008, at 10:31 AM, Lachlan Deck wrote:
    >>
    >>> Perhaps I should describe what I'm actually doing. All I need is a
    >>> way to get a count of a select query (without having to fault in
    >>> all the related objects). So is there a way to trigger that, in
    >>> order to just get a count back, with a SelectQuery without going
    >>> the sqltemplate or namedquery route?
    >>
    >> I think EJBQL route is the way to go for aggregate object queries.
    >> In fact Expression has 'toEJBQLString' method, but you may not even
    >> care about it. Anyways here is an example:
    >>
    >> EJBQLQuery countQuery = new EJBQLQuery("SELECT count(a) FROM Artist
    >> a WHERE a.artistName like 'A%'");
    >
    > The problem is that we have a list controller that's doing its
    > select given the combination of various Expressions. These
    > expressions get broken out (at points) in order to obtain a relevant
    > count via some other query. So I don't have the option of
    > constructing the where clause as simply as above (or, in other
    > words, by hand).
    >
    > i.e., will EJBQLQuery cope with an expression.toString() where clause?
    >
    > with regards,
    > --
    >
    > Lachlan Deck
    >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Jun 10 2008 - 04:03:06 EDT