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 ?
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 ?