restDataStore and fetchPlan

Hi,

I have a simple project with a jmix backend and a jmix frontend, I used restApi addon and restDataStore.

I have setup my model like this. I have some “theme” that contains 1 or * “card”.
I have setup my composition in the client like this :

@JmixEntity
public class Theme {
    @JmixGeneratedValue
    @JmixId
    private UUID id;

    @InstanceName
    private String themeName;

    @NotNull
    private FileRef themeImage;

    @Composition(inverse = "theme")
    private List<Card> cards;

and setup in backend fetchplan

<fetchPlans xmlns="http://jmix.io/schema/core/fetch-plans">
    <fetchPlan class="fr.utbm.crunch.playandpulsemanager.entity.Card" name="card-with-theme" extends="_base">
        <property name="theme" fetchPlan="_base"/>
    </fetchPlan>
    <fetchPlan class="fr.utbm.crunch.playandpulsemanager.entity.Theme" name="theme-with-card" extends="_base">
        <property name="cards" fetchPlan="_base"/>
    </fetchPlan>
</fetchPlans>

and fetchplan in client

<fetchPlans xmlns="http://jmix.io/schema/core/fetch-plans">
    <fetchPlan class="fr.utbm.crunch.playandpulseplayer.entity.Card" name="card-with-theme" extends="_base">
        <property name="theme" fetchPlan="_base"/>
    </fetchPlan>
    <fetchPlan class="fr.utbm.crunch.playandpulseplayer.entity.Theme" name="theme-with-card" extends="_base">
        <property name="cards" fetchPlan="_base"/>
    </fetchPlan>
</fetchPlans>

But when I get Themes, cards was not fetch.

Hi setup collection like this

<collection id="themesDc" class="fr.utbm.crunch.playandpulseplayer.entity.Theme" fetchPlan="theme-with-card">
            <fetchPlan extends="theme-with-card"  />

            <loader id="themesDl" readOnly="true">

            </loader>
        </collection>

Cards are always null, What I’m doing wrong ?

Best regards
Alexandre

I found a solution by doing this

@Install(to = "themesDl", target = Target.DATA_LOADER)
    private List<Theme> themesDlLoadDelegate(final LoadContext loadContext) {
        return dataManager.load(Theme.class).all()
                .fetchPlan("theme-with-card")
                .list();
    }

I think the nested <fetchPlan extends="theme-with-card" /> element takes precedence and the name of the fetch plan is not used. Try to remove this element and keep only fetchPlan="theme-with-card" attribute.

Inline fetch plans will be supported in Jmix 2.5.