Re: NamedQuery / SQLTemplate keyPath validation

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

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

    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%'");
      Number count = (Number) DataObjectUtils.objectForQuery(countQuery);

    Andrus



    This archive was generated by hypermail 2.0.0 : Tue Jun 10 2008 - 03:38:21 EDT