Back to list
TorbenMerrald

jmix-data-loaders

by TorbenMerrald

Equine care management platform for stables - track horses, vaccinations, worm tests, treatments, and automated notifications

1🍴 0📅 Jan 10, 2026

SKILL.md


name: Jmix Data Loaders description: Work with Jmix CollectionLoader, loadDelegate, and LoadContext for custom data loading. Use this skill when implementing custom query logic in views. Use this skill when applying hints to control query behavior. Use this skill when filtering or transforming loaded data programmatically.

Jmix Data Loaders

When to use this skill

  • When implementing custom data loading logic in Jmix views
  • When using loadDelegate to override default loader behavior
  • When applying hints to LoadContext (soft deletion, caching, etc.)
  • When dynamically modifying queries based on UI state
  • When combining multiple data sources or transforming loaded data

Instructions

Basic Loader Setup (XML)

<data>
    <collection id="entitiesDc" class="com.example.Entity">
        <fetchPlan extends="_base">
            <property name="relation" fetchPlan="_base"/>
        </fetchPlan>
        <loader id="entitiesDl" readOnly="true">
            <query>
                <![CDATA[select e from Entity e order by e.name]]>
            </query>
        </loader>
    </collection>
</data>

Using loadDelegate for Custom Loading

Override the default loading behavior with @Install:

@ViewComponent
private CollectionLoader<Entity> entitiesDl;

@Autowired
private DataManager dataManager;

@Install(to = "entitiesDl", target = Target.DATA_LOADER)
private List<Entity> loadDelegate(LoadContext<Entity> loadContext) {
    // Modify the LoadContext as needed
    loadContext.setHint(PersistenceHints.SOFT_DELETION, false);

    // Load using DataManager
    return dataManager.loadList(loadContext);
}

Common LoadContext Hints

import io.jmix.data.PersistenceHints;

// Include soft-deleted entities
loadContext.setHint(PersistenceHints.SOFT_DELETION, false);

// Enable query caching
loadContext.setHint(PersistenceHints.CACHEABLE, true);

Dynamic Query Modification

@Install(to = "entitiesDl", target = Target.DATA_LOADER)
private List<Entity> loadDelegate(LoadContext<Entity> loadContext) {
    LoadContext.Query query = loadContext.getQuery();

    // Modify query string
    if (someCondition) {
        query.setQueryString("select e from Entity e where e.active = true");
    }

    // Add parameters
    query.setParameter("status", selectedStatus);

    return dataManager.loadList(loadContext);
}

Triggering Reload

@ViewComponent
private CollectionLoader<Entity> entitiesDl;

// Reload data when filter changes
@Subscribe("filterField")
public void onFilterChange(ValueChangeEvent event) {
    entitiesDl.load();
}

Important Considerations

  1. Caching: When using dynamic hints, remove cacheable="true" from XML loader to ensure fresh data.

  2. Parameters: Set parameters before calling load():

    entitiesDl.setParameter("status", selectedStatus);
    entitiesDl.load();
    
  3. DataLoadCoordinator: If using <dataLoadCoordinator auto="true"/>, the loader triggers automatically. For manual control, use auto="false" or call load() explicitly.

  4. Fetch Plans: The LoadContext inherits the fetch plan from XML. Modify only if needed:

    loadContext.setFetchPlan(fetchPlans.builder(Entity.class)
        .addAll()
        .build());
    

Score

Total Score

65/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新

+5
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon