Is there way to create composition from MANY_TO_ONE relation on same entity?

Hi, i have entity A which has MANY_TO_ONE relation to self.
How can i create composition of that relation?

Could you explain what do you want to achieve?
Composition is designed to help create/edit linked entities in different screens and then save them all at once. So how do you see your UI screens work?

Hi @knstvk. I want to achieve to see list of related records for my entity. For example.

I have entity A in MANY_TO_ONE relation to same entity (child to parent).

From parent side of relation i want to be able to acces all children records as is possible if you have composition to another table.

For example if we have (this is example of behaviour with two related entities)

A and B entities related with MANY_TO_ONE.

from A side of relation i can see B because there is a key directly in entity.
from B side of relation i can create composition and display list of related records on screen.

You don’t need a composition to see the list of related entities. Just add a collection container with a loader with a query like this:

select a from app_A a where a.parent = :parent

And set the parent parameter in AfterShowEvent listener:

protected void onAfterShow(AfterShowEvent event) {
    myLoader.setParameter("parent", getEditedEntity());

This is kind of uncomfortable since with any other relation you have the oportunitiy to acces data of related records/ record via compostition but for same entity you just cant.