Non-persistent self-reference - How to find the childs for a parent?

Hi, Here is my problem – hope it is just ignorance, that is solvable … at least temporarily. PartCategoryNP has a parent-child relation with itself. Is it possible to find the childs via this relationship? As these are non-persistent entities, I'm not able to use a [reversed]. To solve it, I associated every PartCategoryNP with Binder via the _All association and filter those on the parent object. Workable but it does not  look like the best solution. Thanks for reading! Toon
1 answers

Although the answer comes 2 years too late, maybe it helps someone else still.


You can achieve this by a Java action. Something like this:


 * Provides the list of part category NPs subordinated to a category.
 * @param category
 *            Category whose sub-categrories shall be determined.
 * @return List of subordinated categories.
private List<PartCategoryNP> getSubCategories(PartCategoryNP category)
    final boolean reverseRetrieve = true;
    List<IMendixObject> genericSubCategories = Core.retrieveByPath(getContext(), 
        .toString(), reverseRetrieve);

    List<PartCategoryNP> subCategories = 
        .orElse(java.util.Collections.emptyList()).stream().map(_subCategory -> 
        home.proxies.PartCategoryNP.initialize(getContext(), _subCategory))

    return subCategories;