Skip to content
Advertisement

Java + Postgresql : How to store Parent and List of all children in a HashMap>

I have an sql table Children :

My goal is to construct a java HashMap<String , ArrayList<String>> that contains ParentName as key and a list of ChildrenName as value.

Should I perform the processing by using an sql query? Or select all data and process it via java?

Advertisement

Answer

Concerning your second option:
Get all data from the database with a simple query and map the data in Java

You can do it like this (read the code comments):

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement