Problem saving an entity

Hello,

I made a screen to save an entity but when i save it i got this error:
java.lang.IllegalStateException: Cannot get unfetched attribute [region] from detached object com.wonen.minegocio.entity.EdificacionValorUnitario-bc2515c0-617c-722b-5a2b-1e955190b66d [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.wonen.minegocio.entity.EdificacionValorUnitario._persistence_checkFetched(EdificacionValorUnitario.java)
at com.wonen.minegocio.entity.EdificacionValorUnitario._persistence_get_region(EdificacionValorUnitario.java)
at com.wonen.minegocio.entity.EdificacionValorUnitario.getInstanceName(EdificacionValorUnitario.java:252)
at jdk.internal.reflect.GeneratedMethodAccessor164.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.jmix.core.impl.InstanceNameProviderImpl.getInstanceName(InstanceNameProviderImpl.java:129)
at io.jmix.core.MetadataTools.getInstanceName(MetadataTools.java:205)
at io.jmix.core.MetadataTools.format(MetadataTools.java:158)
at io.jmix.ui.component.impl.ValuePickerImpl.applyDefaultValueFormat(ValuePickerImpl.java:114)
at io.jmix.ui.component.impl.ValuePickerImpl.formatValue(ValuePickerImpl.java:106)
at io.jmix.ui.widget.JmixPickerField.getStringRepresentation(JmixPickerField.java:147)
at io.jmix.ui.widget.JmixPickerField.updateTextRepresentation(JmixPickerField.java:139)
at io.jmix.ui.widget.JmixPickerField.doSetValue(JmixPickerField.java:163)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:140)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:53)
at io.jmix.ui.component.impl.AbstractValueComponent.setValueToPresentation(AbstractValueComponent.java:125)
at io.jmix.ui.component.impl.AbstractValueComponent.setValue(AbstractValueComponent.java:103)
at io.jmix.ui.component.impl.ValuePickerImpl.setValue(ValuePickerImpl.java:134)
at io.jmix.ui.component.impl.EntityPickerImpl.setValue(EntityPickerImpl.java:48)
at io.jmix.ui.component.data.value.ValueBinder$ValueBindingImpl.sourceValueChanged(ValueBinder.java:294)
at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
at io.jmix.ui.component.data.value.ContainerValueSource.containerItemPropertyChanged(ContainerValueSource.java:230)
at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
at io.jmix.ui.model.impl.InstanceContainerImpl.itemPropertyChanged(InstanceContainerImpl.java:182)
at io.jmix.core.entity.BaseEntityEntry.firePropertyChanged(BaseEntityEntry.java:187)
at io.jmix.core.impl.EntityInternals.fireListeners(EntityInternals.java:84)
at com.wonen.minegocio.entity.PresupuestoRevision.setTablaValorUnitario(PresupuestoRevision.java:452)
at io.jmix.core.metamodel.model.utils.MethodsCache$SettersHolder.accept(MethodsCache.java:188)
at io.jmix.core.entity.BaseEntityEntry.setAttributeValue(BaseEntityEntry.java:93)
at io.jmix.core.entity.EntityValues.setValue(EntityValues.java:83)
at io.jmix.ui.model.impl.DataContextImpl.setPropertyValue(DataContextImpl.java:344)
at io.jmix.ui.model.impl.DataContextImpl.mergeState(DataContextImpl.java:324)
at io.jmix.ui.model.impl.DataContextImpl.internalMerge(DataContextImpl.java:235)
at io.jmix.ui.model.impl.DataContextImpl.merge(DataContextImpl.java:179)
at io.jmix.ui.model.impl.DataContextImpl.merge(DataContextImpl.java:190)
at io.jmix.ui.model.impl.DataContextImpl.mergeCommitted(DataContextImpl.java:773)
at io.jmix.ui.model.impl.DataContextImpl.commit(DataContextImpl.java:649)
at io.jmix.ui.screen.StandardEditor.lambda$commitChanges$8(StandardEditor.java:400)
at io.jmix.ui.screen.StandardEditor.commitChanges(StandardEditor.java:415)
at io.jmix.ui.screen.StandardEditor.closeWithCommit(StandardEditor.java:573)
at io.jmix.ui.screen.StandardEditor.commitAndClose(StandardEditor.java:530)
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)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:431)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:396)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1578)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:101)
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:92)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:147)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)

image

I made some tests to find the error and i found that if i dont use atributes in the instanceName method i got no error. In the image i commented a return sentence that works without error: it’s a fixed string. What could be wrong?
image

i’m ataching the project in case is needed:
minegocioJMIX-feat2jmix0.31.zip (394.0 KB)
Thanks in advance for your help.

Hello, I also encountered this problem in cuba7.12. I did not add the wrong object properties to the view. Jmix is currently unclear. Hope to provide some reference.

<property name="countedAssetList" view="_minimal">
    <property name="rfid"/>
    <property name="standardModel" view="_minimal"/>
    <property name="model"/>
    <property name="area" view="_minimal"/>
    <property name="storageLocation"/>
</property>

If I remove the “rfid”.

image

Sorry, it’s version 7.2.12

I think i found the problem. You’ll get the error if you have an entity (PresupuestoRevision) that has an association with a master-detail entities (EdificacionValorUnitario ->[composition] EdificacionValorUnitarioBano ) at the same time.

I had to make a workaround. I eliminate the master table (EdificacionValorUnitario) from the main entity (PresupuestoRevision) and in the screen add a EntityPicker disconected from the datacontainer and by code simulate the association of this component with its detail (EdificacionValorUnitarioBano)

<entityPicker id="tablaValorUnitarioField" metaClass="mngc_EdificacionValorUnitario"
                caption="Tabla Valor Unitario" required="true">
  <actions>
    <action id="lookup" type="entity_lookup"/>
    <action id="clear" type="entity_clear"/>
  </actions>
</entityPicker>

I would like to know if there is another way, or if the framework is going to consider a case like this.