Suppose you have two pojos corresponding to two different table of two different datbase
Pojo1-------entity class corressponding to first table of first database
Pojo2-------entity class corressponding to second table of second database
List listOne = new ArrayList();
List listTwo = new ArrayList();
listTwo.retainAll(listOne);
Note that in these two pojos you have to override hashcode() and equals() method of Object class, because in retainAll, you are comparing the objects of two pojos