Hi,
I have two database tables say TAB1, TAB2.
There are two ejbs for TAB1(EJB1)and TAB2(EJB2). EJB1 gives me a java.util.List of custom Person object. EJB2 also gives a java.util.List of custom Person object.
List1 and List2 has some Person objects common. I need to compare these two List and need to create a new List which has unique of List1 and List2.
Can someone tell which is the best way to do this?
List 1and List2 has more than 3000 Person objects.
-
What is best way to compare!! (5 messages)
- Posted by: Rajarshi Ghosh
- Posted on: June 07 2005 09:57 EDT
Threaded Messages (5)
- List Algebra by Biswa Das on June 07 2005 20:23 EDT
- OOPS by Biswa Das on June 07 2005 20:24 EDT
- OOPS by Rajarshi Ghosh on June 07 2005 23:02 EDT
- You left the common of both in ListB by Biswa Das on June 08 2005 04:31 EDT
- OOPS by Rajarshi Ghosh on June 07 2005 23:02 EDT
- What is best way to compare!! by Tugdual Grall on June 17 2005 21:11 EDT
-
List Algebra[ Go to top ]
- Posted by: Biswa Das
- Posted on: June 07 2005 20:23 EDT
- in response to Rajarshi Ghosh
clone listA---calling listACloned
now listA.removeAll(listB)
now listACloned.removeAll(listA)
Answer is listACloned :-) -
OOPS[ Go to top ]
- Posted by: Biswa Das
- Posted on: June 07 2005 20:24 EDT
- in response to Rajarshi Ghosh
i mis read the question
just use removeAll on both the lists using the other one -
OOPS[ Go to top ]
- Posted by: Rajarshi Ghosh
- Posted on: June 07 2005 23:02 EDT
- in response to Biswa Das
I think it should be
listA.removeAll(listB)
listB.addAll(listA) -
You left the common of both in ListB[ Go to top ]
- Posted by: Biswa Das
- Posted on: June 08 2005 16:31 EDT
- in response to Rajarshi Ghosh
:-( -
What is best way to compare!![ Go to top ]
- Posted by: Tugdual Grall
- Posted on: June 17 2005 21:11 EDT
- in response to Rajarshi Ghosh
Maybe out of context answer.. but why not simply do that in the DB and use a query/view (using a union-distinct) to publish the list in a new EJB?
Regards
Tug