I am trying to optimize the performance of my application, and I observed that on browse screens Jmix is creating queries to load related entities to my browse entity even when I don´t specify the references to these relations in the fetch plan nor in the screen interface.
For example: I have an entity Document that has a composition to DocVersion linked by the reference Document::docDovs. When I load the browser screen for Document, I see one query for DocVersion from each instance of Document on the screen page. Please see below:
2026-08-12 15:51:07.506 DEBUG 17976 — [nio-8080-exec-5] eclipselink.logging.sql : <t 348672877, conn 1013861459> SELECT ID AS a1, DOC_CODE AS a2, DOC_TITLE AS a3, DOC_TYPE AS a4, VERSION AS a5, DOC_ACT_ID AS a6, DOC_PRO_ID AS a7 FROM DOCUMENT LIMIT ?, ?
bind => [0, 50]
2026-08-12 15:51:07.511 DEBUG 17976 — [nio-8080-exec-5] eclipselink.logging.sql : <t 348672877, conn 1006824356> SELECT ID, DOV_CREATION_DATE, DOV_DESCR, DOV_FILE_CHANGE_DATE, DOV_FILE_REF, DOV_ID, DOV_LAST_CHANGE_DATE, DOV_LCS, DOV_UPLOADED, VERSION, DOV_DOC_ID, DOV_APPR_CYCLE_EVT_ID FROM DOC_VERSION WHERE (DOV_DOC_ID = ?) ORDER BY DOV_ID ASC
bind => [03da7f6457524884cbc90a773cabeba0]
2026-08-12 15:51:07.519 DEBUG 17976 — [nio-8080-exec-5] eclipselink.logging.sql : <t 348672877, conn 2137240691> SELECT ID, DOV_CREATION_DATE, DOV_DESCR, DOV_FILE_CHANGE_DATE, DOV_FILE_REF, DOV_ID, DOV_LAST_CHANGE_DATE, DOV_LCS, DOV_UPLOADED, VERSION, DOV_DOC_ID, DOV_APPR_CYCLE_EVT_ID FROM DOC_VERSION WHERE (DOV_DOC_ID = ?) ORDER BY DOV_ID ASC
bind => [05100c5fe372f9b4373c5645a27310d1]
.
.
.
I figured out that the method Document::getDovDocs is called from within Jmix infrastructure, which seems to be causing the lazy loading of all related DocVersion instances. Please see the stack dump below:
java.lang.Exception: Stack trace
at java.base/java.lang.Thread.dumpStack(Thread.java:1391)
at com.calidus.pdcs.entity.documents.Document.getDocDovs(Document.java:102)
at io.jmix.core.entity.BaseEntityEntry.getAttributeValue(BaseEntityEntry.java:85)
at io.jmix.core.entity.EntityValues.getValue(EntityValues.java:100)
at io.jmix.data.impl.EntityAttributesEraserImpl.traverseEntities(EntityAttributesEraserImpl.java:137)
at io.jmix.data.impl.EntityAttributesEraserImpl.collectErasingReferences(EntityAttributesEraserImpl.java:55)
at io.jmix.data.impl.DataStoreInMemoryCrudListener.entityLoading(DataStoreInMemoryCrudListener.java:104)
at io.jmix.core.datastore.DataStoreEntityLoadingEvent.sendTo(DataStoreEntityLoadingEvent.java:85)
at io.jmix.core.datastore.AbstractDataStore.fireEvent(AbstractDataStore.java:353)
at io.jmix.core.datastore.AbstractDataStore.loadList(AbstractDataStore.java:132)
at io.jmix.core.impl.UnconstrainedDataManagerImpl.loadList(UnconstrainedDataManagerImpl.java:112)
at io.jmix.ui.model.impl.CollectionLoaderImpl._load(CollectionLoaderImpl.java:121)
at io.jmix.ui.model.impl.CollectionLoaderImpl.load(CollectionLoaderImpl.java:101)
at io.jmix.ui.component.dataloadcoordinator.OnFrameOwnerEventLoadTrigger.load(OnFrameOwnerEventLoadTrigger.java:48)
at io.jmix.ui.component.dataloadcoordinator.OnFrameOwnerEventLoadTrigger.lambda$new$0(OnFrameOwnerEventLoadTrigger.java:39)
at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
at io.jmix.ui.screen.Screen.fireEvent(Screen.java:150)
at io.jmix.ui.screen.UiControllerUtils.fireEvent(UiControllerUtils.java:58)
at io.jmix.ui.sys.ScreensImpl.fireScreenBeforeShowEvent(ScreensImpl.java:1364)
at io.jmix.ui.sys.ScreensImpl.show(ScreensImpl.java:357)
at io.jmix.ui.sys.ScreensImpl.showFromNavigation(ScreensImpl.java:452)
at io.jmix.ui.menu.MenuItemCommands$ScreenCommand.run(MenuItemCommands.java:193)
at io.jmix.ui.menu.SideMenuBuilder$MenuCommandExecutor.accept(SideMenuBuilder.java:272)
at io.jmix.ui.menu.SideMenuBuilder$MenuCommandExecutor.accept(SideMenuBuilder.java:257)
.
.
.
How can I avoid that?
Thanks in advance.
Ramiro.
Jmix version: 1.7.3
Jmix Studio Plugin Version: 2.6.4-243
IntelliJ version: IntelliJ IDEA 2024.3.7.1 (Community Edition)