Cannot get unfetched attribute ... but attribute is included in view ?

Hi, I am getting an unfetched attribute error, but as far as I understand the attribute is included in the view.
I have no idea what’s going wrong.

The error happens when accessing the “ConcertUnit” attribute of “Concert” entity, from the ConcertPerson edit screen.

Steps to reproduce:

  • From TOJM menu, open Concerts
  • Select sample concert and click “Manage Persons” button. (Performers tab opens)
  • In Performers tab, click add
  • In the dialog window, select a person from the lookupField under “Person”.

Here is the error:
IllegalStateException: Cannot get unfetched attribute [concertUnit] from detached object com.company.tojm.entity.Concert-a86d834a-b5c6-e71b-1839-a9537c3b0f48 [detached].

However, the view used (“concertPersonWithC_CU-view”) contains both “Concert” and “ConcertUnit”…
What am I missing?

Attached please find the project. Thanks for any help!


java.lang.IllegalStateException: Cannot get unfetched attribute [concertUnit] from detached object com.company.tojm.entity.Concert-a86d834a-b5c6-e71b-1839-a9537c3b0f48 [detached].
	at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:98)
	at com.haulmont.cuba.core.sys.persistence.CubaEntityFetchGroup.onUnfetchedAttribute(CubaEntityFetchGroup.java:61)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.processUnfetchedAttribute(EntityManagerImpl.java:2846)
	at com.haulmont.chile.core.model.impl.AbstractInstance._persistence_checkFetched(AbstractInstance.java)
	at com.company.tojm.entity.Concert._persistence_get_concertUnit(Concert.java)
	at com.company.tojm.entity.Concert.getConcertUnit(Concert.java:305)
	at com.company.tojm.web.concertperson.ConcertPersonEdit.lambda$init$1(ConcertPersonEdit.java:67)
	at com.haulmont.bali.events.EventRouter.fireEvent(EventRouter.java:45)
	at com.haulmont.cuba.web.gui.components.WebLookupField.lambda$attachListener$4850968e$1(WebLookupField.java:203)
	at sun.reflect.GeneratedMethodAccessor117.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:200)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:163)
	at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1037)
	at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:1181)
	at com.vaadin.ui.AbstractField.setValue(AbstractField.java:580)
	at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:742)
	at com.vaadin.ui.AbstractField.setValue(AbstractField.java:474)
	at com.vaadin.ui.ComboBox.changeVariables(ComboBox.java:750)
	at com.haulmont.cuba.web.toolkit.ui.CubaComboBox.changeVariables(CubaComboBox.java:162)

tojm_sample.zip (2.5M)

1 Like

Hi Matthis,

Thank you for your sample project. We have looked at it.

The “tojm$ConcertWithCp.edit” screen is opened with the view which does not contain a link to “ConcertUnit”.
To solve the problem add the “concertUnit” attribute to the “concertWithCP” view.

Let me explain the reason:

In your project, “Concert” is a composition of “ConcertPersons”. Composition entities should be persisted together, and the platform does not reload “Detail” entity when its editor is opened from “Master” editor.

“ConcertUnit” edit-screen is opened from the “Concert” edit-screen.

So “ConcertPersons” edit-screen receives all data from the parent screen (where the “concertUnit” attribute is unfetched).

Regards.

Hi Rotislav,

Thank you very much for taking the time to look at the uploaded project.

Understood that the platform does not reload “Detail” entity when editor is opened from “Master” editor - now that it makes sense it is easy to fix! Solved.

Thanks again for your clear explanation.
Best regards,

Matthis