Fetch plan for polymorphic entities

Take an abstract entity Vehicle with subtypes Car, Motorbike, and Truck (use any inheritance strategy you want, even SINGLE_TABLE)

How do you specify the attributes of the subtypes in a fetchGraph of Vehicle?

I tried with:

dataManager.load(Vehicle.class)
    .condition(...)
    .fetchPlanProperties(
        "brand",           // OK if defined on Vehicle
        "fourWD",          // FAILS if defined on Car
        "maxTons",         // FAILS if defined on Truck
    )
    .list();

but I get:

IllegalArgumentException: Property 'fourWD' not found in test_Vehicle

How do I specify something like this?

This would be trivial to do in either SQL or JPQL with just a LEFT JOIN.

Hi Tobia,

Unfortunately, Jmix doesn’t support fetch plan with inheritance (the same behavior is in CUBA: Polymorphic views)

As workaround, you can load data by several queries:

dataManager.load(Car.class)
    .condition(...)
    .fetchPlanProperties(
        "brand",           
        "fourWD",        
    )
    .list()

dataManager.load(Truck.class)
    .condition(...)
    .fetchPlanProperties(
        "brand",           
        "maxTons",         
    .list()