view raw
Nikita Pandey Nikita Pandey - 5 months ago 24
Java Question

Clubbing query result based on single column data in JAVA

Suppose below is the query Result:

Metrix No. Org Bus unit Juris Title
821 ABC ABC Business AZ AZ cleanup
923 PQR PQR Business CT CT Cleanup
923 PQR PQR Business N4 N4 Cleanup
923 PQR PQR Business N4 N4 add page
923 PQR PQR Business N3 N3 Cleanup

I want the result page as shown below:

Corp. Entity Customer Segment State Project Description
ABC ABC Business AZ AZ Cleanup
PQR PQR Business CT,N4,N3 CT Cleanup

Query result in stored in a bean. So we have a arraylist from where we get data in each row. I thought of using Map but it will store only 2 values at a time and I need 4 values corresponding to each record.

Can someone please suggest me some solution for this?



Thanks for your input, but using MAP was not feasible for me.

So I made one method which takes 'org' , the entire records and the index ( from where the iteration on records would start) as input parameter and gives STATE(as mentioned in result page) as output.

I also created one more Bean which had only those values which were required by the result page. I iterated the main list of records and whenever got new org , I passed the details to the method which provided me the combined State list. Then these values (Corp. Entity, Customer Segment, State , Project Description) was entered into new Bean.

Now while displaying the data, I iterated it through Array of new Bean which had only 4 values.