Hi,
i have a Class Category which has subcategories collection of type Category. Each Category object has also a superCategory reference to it's parent Category object, so it's typical tree structer with many roots possible. All i need to do is to retreive all my Category objects from database as tree structer, not as a list of all Category objects but as a list of root level Category objects and eagerly retreived subcategories, and subcategories of subcategories and so on.
I tried this
Code:
session.createCriteria(Category.class).add(Expression.isNull("superCategory")).setFetchMode("subcategories",FetchMode.EAGER).list();
but is retreives just a plain list of all Category objects, not a tree structer.
Example of my tree structure could be as below:
Category
-Category
--Category
--Category
---Category
---Category
--Category
---Category
Category
-Category
--Category
---Category
The question is: how to retreive all Category objects as a tree structer?
Thanks for any helpful answers