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