InstanceContainer fetchPlan ignores child property fetch plans when multiple for same type

Jmix 2.1.1

I have a standard detail view for an Entity that contains multiple association fields for the same Member type. I want the loading of the screen to be as efficient as possible, so I am listing those child properties in the fetch plan of the InstanceContainer. Also, studio warns the properties are not included in the fetch plan if I don’t do this. I was hoping they would be loaded eagerly with the main query and only retrieve the _instance_name columns, but both of those things are not happening.

Problem 1
It appears to only use the fetch plan for the first child property and ignores the rest. For example, the following definition will use _base for fetching all 7 Member entities:

<instance id="memberPromotionDc" class="org.ajjf.membership.entity.MemberPromotion">
    <fetchPlan extends="_base">
        <property name="member" fetchPlan="_base"/>
        <property name="examiner1" fetchPlan="_instance_name"/>
        <property name="examiner2" fetchPlan="_instance_name"/>
        <property name="examiner3" fetchPlan="_instance_name"/>
        <property name="examiner4" fetchPlan="_instance_name"/>
        <property name="caller" fetchPlan="_instance_name"/>
        <property name="uke" fetchPlan="_instance_name"/>
    </fetchPlan>
    <loader/>
</instance>

Question / Problem 2
Should a detail view be able to load associated entities eagerly? No matter what I try the InstanceContainer always loads them in separate queries. This approach does work for standard list views and CollectionContainers.

Thanks!

Hello Jeff,

Problem 1:
It is expected behaviour because in several cases when the same entity occurs in a graph of loaded entities several times but with different fetch plans it may lead to one bug.
In order to avoid this situation set of local attributes are completed with union of all local attributes this entity class have in current fetch plan.

The issue has been created in order to try to improve this behaviour.

Question / Problem 2
You can use property “fetch” to control fetch mode:

    <fetchPlan extends="_base">
        <!-- Fetching in the same select by joining with referenced table: -->
        <property name="member" fetchPlan="_base"  fetch="JOIN"/> 
         <!-- ... -->
    </fetchPlan>

Regards,
Dmitry

Thanks for the explanation. I am most concerned about consolidating the additional queries, so if there is a reason the different fetch plans are not supported - that is OK with me. I will try the fetch=“JOIN” soon.