In context of a web application, Is it suitable to do some JOIN operation in Java, on the data retrieved from the database(from first query), and use that \"JOIN\"ed
For sure, you can do a fast JOIN in Java. I know only about three reasons against doing it:
Without an SQL DB you have no choice, anyway. So, assuming the simplest case, i.e., joining on a condition like A.x = B.x
, you can do it easily by computing the intersection using Set.retainAll
. For each member of the intersection you need to combine all corresponding rows from the first table with all corresponding rows from the second one.
Assuming there are no more interesting columns in the tables, you're done. Otherwise you need to attach them somehow. In case x
is unique in both A
and B
you can use Maps, otherwise you need a Multiset (there are many implementations available, e.g., in Guava).