# Collectors

Published articles for Collectors.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## How to Turn a List of Flat Elements into a Hierarchy in Java, SQL, or jOOQ

DevFeed: [How to Turn a List of Flat Elements into a Hierarchy in Java, SQL, or jOOQ](<https://devfeed.tech/articles/how-to-turn-a-list-of-flat-elements-into-a-hierarchy-in-java-sql-or-jooq-28945.md>)

Original publisher: [Read original article](<https://blog.jooq.org/how-to-turn-a-list-of-flat-elements-into-a-hierarchy-in-java-sql-or-jooq/>)

Author: lukaseder

Published: 2023-03-24T15:45:28Z

Content type: tutorial

Language: en

Sources: [jOOQ](<https://devfeed.tech/sources/jooq.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Jackson](<https://devfeed.tech/topics/jackson.md>), [JSON](<https://devfeed.tech/topics/json.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [collections](<https://devfeed.tech/tags/collections.md>), [collector](<https://devfeed.tech/tags/collector.md>), [collectors](<https://devfeed.tech/tags/collectors.md>), [hierarchical-sql](<https://devfeed.tech/tags/hierarchical-sql.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [jackson](<https://devfeed.tech/tags/jackson.md>), [java](<https://devfeed.tech/tags/java.md>), [jooq-development](<https://devfeed.tech/tags/jooq-development.md>), [json](<https://devfeed.tech/tags/json.md>), [nested-collections](<https://devfeed.tech/tags/nested-collections.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [recursive-sql](<https://devfeed.tech/tags/recursive-sql.md>), [sql](<https://devfeed.tech/tags/sql.md>)

### AI overview

A tutorial on converting flat parent-child data into hierarchical structures using SQL, Java, or jOOQ. It compares a recursive PostgreSQL query with jOOQ 3.19 and a reusable pure-Java Collector, and discusses JSON serialization with Jackson and type inference considerations.

### Source excerpt

Occasionally, you want to write a SQL query and fetch a hierarchy of data, whose flat representation may look like this: The result might be: |id |parent_id|label | |---|---------|-------------------| |1 | |C: | |2 |1 |eclipse | |3 |2 |configuration | |4 |2 |dropins | |5 |2 |features | |7 |2 |plugins | |8 |2 ... Continue reading How to Turn a List of Flat Elements into a Hierarchy in Java, SQL, or jOOQ ->