Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 65181 invoked from network); 1 Jun 2007 18:11:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Jun 2007 18:11:20 -0000 Received: (qmail 89984 invoked by uid 500); 1 Jun 2007 18:11:23 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 89970 invoked by uid 500); 1 Jun 2007 18:11:23 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Delivered-To: moderator for user@cayenne.apache.org Received: (qmail 87710 invoked by uid 99); 1 Jun 2007 18:08:31 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=MSGID_FROM_MTA_HEADER,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Date: Fri, 01 Jun 2007 11:08:03 -0700 From: Matt Kerr To: user@cayenne.apache.org Message-ID: <586D77E2-0112-1000-9B30-A8D0C159149E-Webmail-10016@mac.com> in-reply-to: references: <49D23F7404DC5B4086D7352312597E0F01115C5E@FNHH-SVMEXDB002.Freenet-AG.de> Subject: Re: performing count MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 209.191.174.4 X-Brightmail-Tracker: AAAAAA== X-Brightmail-scanned: yes X-Virus-Checked: Checked by ClamAV on apache.org Here's some random feedback .. I have the need for row counting here and there, so having support in cayenne would be great. Couple things .. >int rowCount = new CountQuery(Artist.class).getCount(); I don't see how this works without a DC - ? (Maybe I'm just missing something obvious ..) And, for me personally, .. The notion of "utility" means 'weakly understood' .. so, I try and avoid anything for the 'utility' junk box as much as humanly possible. If it's real, and ligit, I try like heck to find a real home (abstraction) where it would reside. Also another personal preference .. I dislike the vague names 'getCount' :-/ If I was reading someone else's code, I wouldn't mind seeing something like: int n = Artist.numberOfRowsMatchingQuery(dc, q); where q==null counts all. I think from the OO side of things (which is the whole point of ER -> OO), that's really what you're after. I'd rather make the ~base class support rich - than spread stuff into 'utility' classes here and there. Food for thought. Dunno if it's even plausible. 2cents. Thanks, -Matt On Friday, June 01, 2007, at 11:45AM, "Michael Gentry" wrote: >Looking at that CountQuery class makes me think we should actually add it to >Cayenne as a utility class. Perhaps with two additional methods added: > >public int getCount(); >public int getCount(DataContext dc); > > >That way you could then do: > >CountQuery query = new CountQuery(Artist.class); >int rowCount = query.getCount(); > >or even: > >int rowCount = new CountQuery(Artist.class).getCount(); > >I think that would simplify things and needing a count is a pretty comment >activity. Perhaps for more flexibility, it would be good to have a >constructor that could take a WHERE clause, too, in case you only need >counts matching certain criteria. > >Thoughts? > >/dev/mrg >