| Id | Child_one_id | Child_two_id | Parent_id |
|---|---|---|---|
| 1 | 2 | 3 | null |
| 2 | null | null | 1 |
| 3 | 2 | null | 1 |
| 4 | null | null | null |
| 5 | 6 | 7 | null |
| 6 | null | null | 5 |
| 7 | 6 | null | 5 |
| 8 | null | null | null |
| 9 | null | null | null |
| 10 | 11 | 12 | null |
| 11 | null | null | 10 |
| 12 | null | null | 10 |
I want to sort using orderBy in PostgreSQL Data like 10, 11,12,9,8,5,6,7,4,1,2,3, which was Id descending and if that id contains child_one_id and child_two_id then that will be followed as predecessor in sort order.
All id's have been linked in the table like the above.
currently i am retriving only id in desc order via CriteriaBuilder in Java, But in CriteriaBuilder i have additionally joined more than 10 tables, because that other table column values also needs to fetch to produce output in Java.
So it is possible with crtieriaBuilder in java to achieve this ?