I am trying to resolve a problem which i am currently facing. I am trying to find out which is the fastest way to retrieve information from a database.
So a managers name is passed in, what i need to do is return all the users who's manager is passed in, but if any of these users happen to be a manager, i have to return all the user names (
List<String>) they manage also... this will repeat until i return everyone
here is a small example of what i need to return
manager --> manager --> manager --> manager --> employee --> manager --> employee --> manager --> manager --> manager --> employee --> employee
so in the example above the code would be returning 12 names
i know i could do this a number of different ways but i do not know which would be the best way (recursive for loop, for loop recursively calling method, SQL statement, HQL statement ... etc.)
As this list can be any size depending on the manager passed in, i need to find which would be the quickest way to retrieve this as i have coded this to use recursive for loops and it takes 1 minute 20 seconds which is WAY too long