Join collections of business object
Hi all,
I have a project which involves join of business objects... Which means, I ALREADY got collections of business objects from the DB.(e.g. a list of customers and a list of Orders).
Now I want to join them at the object level, like an SQL statement on object level... Which will returns a list of object contains the information I want after join
Note that the point is NOT to involve any DB. I have did a bit re-search. HQL from Hibernate is not what I want since that still involves Database. something like JDO is also not what I want...
Are there any similar projects that you guys know about? Or can you suggest me which direction I can go to solve the problem?
Many thanks.
H
[731 byte] By [
ZHXa] at [2007-11-26 23:35:51]

# 3
> Problem is those objects are
> all POJO... like a bean object...
How could this be a problem ?
As I say: "can't you aggregate them so that a customer object to have a list of orders ?" You can get them from the database already agregated, and so the join is done ? Do you need something more ?
# 4
Hi,
Thank you for your reply.
The business objects are generated from some existing Jini-based services, I am not supposed to modify the already-working services, as they are widely used by other applications...
I am only told to use those objects provided by those services.
Cheers
H
ZHXa at 2007-7-11 14:57:52 >

# 5
> Which means, I ALREADY got collections of business objects from the DB.(e.g. a list of customers and a list of Orders).
During the process a list of orders will be built for each customer.
A solution is based on the construction of a map from customers list (key:customerID -> value:customer object). To do this customer class must implement equals and hashCode. Does customer class has implemented these, or are you allowed to implemet these in the class ? Then you iterate over the orders and using customerID from order objects you put them in the coresponding customer list.
If you can't, you must take another solution where you sort the customers and orders lists, both by customers ids (here you must create some comparators, but they do not depend on the existing system as in previous solution). Then you iterate through both lists simultaneously and put the order objects in corresponding customer lists (this is some sort of merge algorithm).