KeyValueCollection, nested entities and views

Hello community,

I have following keyValueCollection:

<keyValueCollection id="boothStatsBaseViewsDc">
    <loader id="boothStatsBaseViewsDl">
        <query>
            <![CDATA[
                select
                    e.booth,
                    count(e) as nDays,
                    avg(e.grossSponsorCount) as grossSponsorAvg,
                    avg(e.netSponsorCount) as netSponsorAvg
                from didi_BoothStatsBaseView e
                join fetch e.booth
                left join fetch e.booth.department
                left join fetch e.booth.address
                group by e.booth
            ]]>
        </query>
    </loader>
    <properties>
        <property name="booth" class="de.dialogdirect.didi.entity.booth.Booth"/>
        <property name="nDays" datatype="int"/>
        <property name="grossSponsorAvg" datatype="double"/>
        <property name="netSponsorAvg" datatype="double"/>
    </properties>
</keyValueCollection>

The problem is: I want to display the booth property as table column, so the booth name pattern applies. The name of entity Booth is calculated from properties of Department entity Booth.department and Address entity Booth.address. The according name pattern is defined as @NamePattern("#getCaption|isJobInfoBooth,isPlaceHolder,department,address") with isBlahblah being boolean properties of Booth.

As I don’t see any way to select or define view for association properties as in regular collection DCs (the propertyelement has no viewattribute for this container type), I resorted to join fetchs. I also tried regular joins. In both cases, I get the following error when the screen containing the table is shown:

Unfetched attribute access error

It usually occurs when the attribute is not included into a view
Entity: de.dialogdirect.didi.entity.booth.Booth
Attribute: department

So, how do I tell CUBA declaratively to load Booth and its properties department and address with view _minimal?

Thanks for your help,
Manuel

Hi Manuel,

There is no way to specify a view for a KeyValueContainer property.
In theory, join fetch should have made sure the references are loaded. I don’t know why it doesn’t work in your case.
As a workaround, you can load your data in a custom service and map to a KeyValueEntity to put in the data container and show in a table.

Regards,
Konstantin