Error with userIndicator after extend User entity (cuba 6.10.7)

Hello!

I’ve extended User entity with new fields. All ok, except when I try to change to substituded user there is Exception:

IllegalStateException: Cannot get unfetched attribute [name] from detached object com.company.nl.entity.ExtUser-ea95eb71-2375-1caf-ead7-3c3fffd8bbbf [detached].

All other screens work ok
How to set right view to UserIndicator when user is changed?

Below full error log:

    java.lang.IllegalStateException: Cannot get unfetched attribute [name] from detached object com.company.nl.entity.ExtUser-ea95eb71-2375-1caf-ead7-3c3fffd8bbbf [detached].
	at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:98)
	at com.haulmont.cuba.core.sys.persistence.CubaEntityFetchGroup.onUnfetchedAttribute(CubaEntityFetchGroup.java:74)
	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.haulmont.cuba.security.entity.User._persistence_get_name(User.java)
	at com.haulmont.cuba.security.entity.User.getName(User.java:130)
	at com.haulmont.cuba.web.gui.components.mainwindow.WebUserIndicator$SubstitutedUserChangeListener.valueChange(WebUserIndicator.java:234)
	at sun.reflect.GeneratedMethodAccessor411.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:1199)
	at com.vaadin.ui.AbstractField.setValue(AbstractField.java:600)
	at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:738)
	at com.vaadin.ui.AbstractField.setValue(AbstractField.java:494)
	at com.vaadin.ui.ComboBox.changeVariables(ComboBox.java:750)

Solved problem by adding such view.

   <view class="com.haulmont.cuba.security.entity.UserSubstitution"
          extends="app"
          name="app">
        <property fetch="AUTO"
                  name="user"
                  view="_local"/>
        <property fetch="AUTO"
                  name="substitutedUser"
                  view="_local"/>
        <property name="startDate"/>
        <property name="endDate"/>
    </view>

This is correct or may be other solution?

Hi,

Would be great to see a test project where the problem is reproduced. Normally you shouldn’t extend the view for substitution to work.

Hello,

I have the same problem with CUBA 7.0.7 and this view solved the problem too.

Greetings
Andreas

Hi.
Unfortunately, we cannot reproduce the problem. Could you please share the extended User entity or a small project in order to help us investigate the problem?