Re: performing count

From: Matt Kerr (mr_matt_ker..ac.com)
Date: Fri Jun 01 2007 - 14:08:03 EDT

  • Next message: Michael Gentry: "Re: performing count"

    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" <blacknex..mail.com> 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
    >



    This archive was generated by hypermail 2.0.0 : Fri Jun 01 2007 - 14:11:22 EDT