JSF is definitely the wrong forum, but I'm not sure whether
JDBC or
Java in General is a better fit. You haven't made clear whether it's the recursion or the retrieving from a database that's giving you the trouble. Well, let's try JDBC and see how that goes.
Would you be able to retrieve a single record from the database given its ID?