GROUP BY for collection of javabeans

J

js

I was wondering, is there some kind of API to have a "GROUP BY"
functionality for collection of javabeans ? For example, given a Javabean:

public class A {

public int getProductId() { ... }
public Date getDay() { ... }
public double getItemsSold() { ... }

}

.... and have a collection of these, I then want to say return the total
items sold by day ... or total items sold by productId ... or average, etc.

In a sense, sort of a sql group by for javabean collections.
The collection of javabeans may OR may not come from an RDBMS.

I could do it all by hand for each type of bean, but I was thinking that
there should be a more elegant way of doing this. Probably someone has come
across this requirement before.

Even if the collection was taken as a ResulSet from a database, instead of
hitting the database with more than one query, since I already have the
collection, why ask the database again for a summary ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top