I have a List<HashMap<String,Object>>
which represents a database where each list record is a database row.
I have 10 columns in my database. There are several rows where the values of 2 particular columns are equals. I need to remove the duplicates from the list after the list is updated with all the rows from database.
What is the efficient way?
FYI - I am not able to do distinct while querying the database, because the GroupName is added at a later stage to the Map
after the database is loaded. And since Id column is not primary key, once you add GroupName to the Map
. You will have duplicates based on Id + GroupName combination!
Hope my question makes sense. Let me know if we need more clarification.