cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: NamedQuery / SQLTemplate keyPath validation
Date Tue, 10 Jun 2008 07:37:41 GMT

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



Mime
View raw message