Does lazy loading ignore soft delete?

Hi all,

I have debugged a case where already deleted items were visible in the UI.
As an example I have a screen where I can select employees from a company. The company is set as a private field in the screen with a setter before showing the screen. The company does not include the employees, meaning they are not loaded at that point.

In the screen onInitEntity I use company.getEmployees() which will then cause a lazy load of the employees. After that I have a list of employees in my company entity but it also includes soft deleted items.

Is this an intended bahaviour or can it be configured somewhere?

Thanks for any reply! :slight_smile:

What mechanism did you use to get the
company?

datamanager? entitymanager? native query?

sounds like you are using a mechanism that doesn’t take soft deletion into account.

Thanks for the idea but the company is loaded using the dataManager and the company has no problem. It is an attribute (a list to be precise) that gets loaded after that into the company that has deleted entities. And I am not loading the attribute, it is done by lazy loading.

I’m guessing it is not related to lazy loading but to the handling of references Soft Deletion :: Jmix Documentation

Let’s say you have a company that has employees.
You have another entity like a File that has a reference to an employee.
You soft delete a certain employee that is referenced from a file.

If you now open the file, what do you expect to see? Depending on your reference handling it could be that the file still shows the old employee for historical reasons, but you will not be able to select that employee in a list anymore.

Thanks, I guess for some use cases it makes sense.
In my use case, the employees are a 1:n relation and should not be loaded when they are deleted.

Another weird use case I have, the company has a 1:1 relation object called “Activities” and there is beside other stuff a 1:n list of single activities. When I delete everything in that list and open an editor for the company and use “getEditedEntity().getActivities()” which is the 1:1 object, it gets loaded and also the 1:n list inside that object is loaded with deleted entities although I never accessed them.

Maybe I will make an example project for it, maybe it is supposed to do that but it is highly inconvenient.

did you specify a fetch plan? cause that’s exactly what fetch plans do, specify what to eager load.

further jmix supports lazy loading in the UI layer, see Fetching Data :: Jmix Documentation

Thank you, yes, I am using a fetchPlan in the UI descriptor and the attributes are NOT part of the fetchPlan, so the UI layer does lazy loading in them and by that loads deleted entities.
I can see in the debugger, that if an attribute is missing, the lazy loading creates a loadContext for the main entity and adds a fetchPlan with the missing attribute and ALSO sets the soft delete flag to false.
This may be correct according to the documentation because my attribute is a 1:1 relation. But after loading the attribute, it also contains its own attributes including a list of 1:n attributes with deleted entries.