Cannot get unfetched attribute [password] from detached object

Jmix version: 1.1.2
Jmix Studio plugin version: 1.1.4-213
IntelliJ IDEA 2021.3 CE - Build #IC-213.5744.223, built on November 27, 2021
Operating System: macOS 12.0.1 (21A559)
File System: Case-Sensitive Journaled HFS+ (APFS)
Datebase: PostgreSQL 13

Hi Everyone

For your information, since my CUBA-to-Jmix migration (originally done with v1.1.1) I am having many problems with my fetchPlans. I have to keep adding attributes to the Jmix fetchPlans to avoid “IllegalStateException: Cannot get unfetched attribute” errors that I did not have in CUBA and one of these errors that keeps repeating itself is the one below with the User password. In many of my entities I have a “creator” attribute referencing the User entity…

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CREATOR_ID")
@OnDeleteInverse(DeletePolicy.DENY)
protected User creator;

but I only access the User password in one screen where I give the user the option to change his password. The error below occurs in a completely different screen that does not use the password attribute anywhere. And please also note that several weeks ago in a separate entity fetchPlan I added the password to avoid this error but then I received an new error for the “unfetched attribute [active]” User attribute and I do not access the User’s “active” attribute in any of my screens.

I cannot reproduce this behavior with a simple project, so I would like to know if this is a known issue or maybe the side effect from another fetchPlans issue? Any suggestions?

Best regards
Chris

java.lang.IllegalStateException: Cannot get unfetched attribute [password] from detached object com.company.nf.entity.User-50c5ecc7-8bf2-d8c9-faa9-ea00e61bfce8 [detached].
at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:100)
at io.jmix.eclipselink.impl.JmixEntityFetchGroup.onUnfetchedAttribute(JmixEntityFetchGroup.java:67)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.processUnfetchedAttribute(EntityManagerImpl.java:3027)
at com.company.nf.entity.User._persistence_checkFetched(User.java)
at com.company.nf.entity.User._persistence_get_password(User.java)
at com.company.nf.entity.User.getPassword(User.java:98)
at io.jmix.core.entity.BaseEntityEntry.getAttributeValue(BaseEntityEntry.java:85)
at io.jmix.core.entity.BaseEntityEntry.setAttributeValue(BaseEntityEntry.java:101)
at io.jmix.core.entity.EntityValues.setValue(EntityValues.java:89)
at io.jmix.ui.model.impl.DataContextImpl.setPropertyValue(DataContextImpl.java:342)
at io.jmix.ui.model.impl.DataContextImpl.setPropertyValue(DataContextImpl.java:336)
at io.jmix.ui.model.impl.DataContextImpl.mergeState(DataContextImpl.java:282)
at io.jmix.ui.model.impl.DataContextImpl.internalMerge(DataContextImpl.java:236)
at io.jmix.ui.model.impl.DataContextImpl.mergeState(DataContextImpl.java:312)
at io.jmix.ui.model.impl.DataContextImpl.internalMerge(DataContextImpl.java:236)
at io.jmix.ui.model.impl.DataContextImpl.mergeState(DataContextImpl.java:312)
at io.jmix.ui.model.impl.DataContextImpl.internalMerge(DataContextImpl.java:236)
at io.jmix.ui.model.impl.DataContextImpl.merge(DataContextImpl.java:180)
at io.jmix.ui.model.impl.DataContextImpl.merge(DataContextImpl.java:191)
at io.jmix.ui.model.impl.DataContextImpl.mergeCommitted(DataContextImpl.java:775)
at io.jmix.ui.model.impl.DataContextImpl.commit(DataContextImpl.java:651)
at io.jmix.ui.screen.StandardEditor.lambda$commitChanges$9(StandardEditor.java:427)
at io.jmix.ui.screen.StandardEditor.commitChanges(StandardEditor.java:455)
at io.jmix.ui.screen.StandardEditor.closeWithCommit(StandardEditor.java:616)
at io.jmix.ui.screen.StandardEditor.commitAndClose(StandardEditor.java:570)
at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
at io.jmix.ui.action.BaseAction.actionPerform(BaseAction.java:220)
at io.jmix.ui.component.impl.ButtonImpl.buttonClicked(ButtonImpl.java:75)
at io.jmix.ui.widget.JmixButton.fireClick(JmixButton.java:77)
at com.vaadin.ui.Button$1.click(Button.java:57)

Hello Everyone

In my initial post above the error occurred during a commit and now I just received the same error (below) but this time while creating a new entity in a browse screen and passing it on to the edit screen. I had performed this same create action several times without a problem (I’m testing things) and now I suddenly have this error again. I do not access the password attribute in this edit screen either.

Best regards
Chris

java.lang.IllegalStateException: Cannot get unfetched attribute [password] from detached object com.company.nf.entity.User-60885987-1b61-4247-94c7-dff348347f93 [detached].
at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:100)
at io.jmix.eclipselink.impl.JmixEntityFetchGroup.onUnfetchedAttribute(JmixEntityFetchGroup.java:67)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.processUnfetchedAttribute(EntityManagerImpl.java:3027)
at com.company.nf.entity.User._persistence_checkFetched(User.java)
at com.company.nf.entity.User._persistence_get_password(User.java)
at com.company.nf.entity.User.getPassword(User.java:97)
at io.jmix.core.entity.BaseEntityEntry.getAttributeValue(BaseEntityEntry.java:85)
at io.jmix.core.entity.BaseEntityEntry.setAttributeValue(BaseEntityEntry.java:101)
at io.jmix.core.entity.EntityValues.setValue(EntityValues.java:89)
at io.jmix.ui.model.impl.DataContextImpl.setPropertyValue(DataContextImpl.java:342)
at io.jmix.ui.model.impl.DataContextImpl.setPropertyValue(DataContextImpl.java:336)
at io.jmix.ui.model.impl.DataContextImpl.mergeState(DataContextImpl.java:282)
at io.jmix.ui.model.impl.DataContextImpl.internalMerge(DataContextImpl.java:236)
at io.jmix.ui.model.impl.DataContextImpl.mergeState(DataContextImpl.java:312)
at io.jmix.ui.model.impl.DataContextImpl.internalMerge(DataContextImpl.java:225)
at io.jmix.ui.model.impl.DataContextImpl.merge(DataContextImpl.java:157)
at io.jmix.ui.model.impl.DataContextImpl.merge(DataContextImpl.java:166)
at io.jmix.ui.screen.StandardEditor.setupEntityToEdit(StandardEditor.java:214)
at io.jmix.ui.screen.StandardEditor.beforeShow(StandardEditor.java:155)
at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
at io.jmix.ui.screen.Screen.fireEvent(Screen.java:124)
at io.jmix.ui.screen.UiControllerUtils.fireEvent(UiControllerUtils.java:58)
at io.jmix.ui.sys.ScreensImpl.fireScreenBeforeShowEvent(ScreensImpl.java:1361)
at com.haulmont.cuba.web.sys.CubaScreens.fireScreenBeforeShowEvent(CubaScreens.java:651)
at io.jmix.ui.sys.ScreensImpl.show(ScreensImpl.java:354)
at io.jmix.ui.screen.Screen.show(Screen.java:306)
at com.company.nf.web.screens.search.SearchInterestsBrowse.showCreateEditorForInterest(SearchInterestsBrowse.java:245)
at com.company.nf.web.screens.search.SearchInterestsBrowse.onCreateBtnCreatePerfSearch(SearchInterestsBrowse.java:229)
at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
at io.jmix.ui.action.BaseAction.actionPerform(BaseAction.java:220)
at io.jmix.ui.component.impl.PopupButtonImpl.lambda$setPopupButtonAction$1(PopupButtonImpl.java:321)
at io.jmix.ui.widget.JmixButton.fireClick(JmixButton.java:77)
at com.vaadin.ui.Button$1.click(Button.java:57)

It’s hard to say what is the cause without an example. Try to just use the _base fetch plan - it loads all local attributes eagerly and allows lazy loading of references if needed.

@krivopustov

Hello Konstantin

Thank you for the feedback and your efforts. I will try your _base suggestion the next time this occurs and also try to identify the particular use case that is causing this.

Best regards
Chris