HQL recursion, how do I do this?

前端 未结 3 1413
再見小時候
再見小時候 2020-12-03 14:20

I have a tree structure where each Node has a parent and a Set children. Each Node has a String title, and I want to make

3条回答
  •  借酒劲吻你
    2020-12-03 15:15

    While it isn't possible to write the recursive query you're asking for, it is possible to eager fetch the hierarchy with HQL; doing this would at least allow you to walk the tree in memory without hitting the database for each level.

    select n from Node n
    left join fetch n.Children
    

提交回复
热议问题