There are two ways to achieve the desired effect, and neither of them is available in standard DQL with the schema provided.
First, you might choose to use a recursive SQL query to get the proper ordering in each subtree. You'll need to map the results of the native query to be able to work on ORM objects again.
The other way is to add an extra column to the table, and store the full path (or any global positioning information) of each node. After this, a quick ORDER BY
works flawlessly even in DQL. You might find the tree behavior extension handy to automate most parts.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.