Cannot get unfetched attribute from detached object [detached]

About environment: Jmix 2.0.0

Hi, I have a question about famous error

I have 2 entity named CmParValue (Denomination of a currency) and GdExchangeRate (exchange rate at a specified time of a denomination of a currency).
It’s One direction oneToMany relationship so i only have a set of CmParValue in GdExchangeRate
image
So i use a table named GD_EXCHANGE_RATE_CM_PAR_VALUE to save id of CmParValue and id of GdExchangeRate
The problem happen when I try to check if exchange rate at a specified time of a denomination of a currency already existed then pop-up an error.
image
But it seems like jmix doesnt understand the value from the GD_EXCHANGE_RATE_CM_PAR_VALUE and i get the “unfetched attribute” error
Any way to fix this?

  1. GdExchangeRate entity
    image
  2. CmParValue entity doesnt have any special things
  3. xml
    ‘’’
<?xml version="1.0" encoding="UTF-8" standalone="no"?>










    <collection id="gdCurrencyPairDc" class="com.fis.pbcapcore.entity.GdCurrencyPair">
        <fetchPlan extends="_base"/>
        <loader id="gdCurrencyPairDl" readOnly="true">
            <query>
                <![CDATA[select e from GdCurrencyPair e where e.deleted = 'N' and e.ccy2Id.ccyCode = 'VND']]>
            </query>
        </loader>
    </collection>

    <collection id="cmParValueDc" class="com.fis.pbcapcore.entity.CmParValue">
        <fetchPlan extends="_base"/>
        <loader id="cmParValueDl" readOnly="true">
            <query>
                <![CDATA[select e from CmParValue e where e.deleted = 'N']]>
            </query>
        </loader>
    </collection>

    <instance id="gdExchangeRateDc" class="com.fis.pbcapcore.entity.GdExchangeRate">
        <fetchPlan extends="_local">
            <property name="ccyId" fetchPlan="_local"/>
            <property name="ccy1ParValueId" fetchPlan="_local" fetch="AUTO"/>
        </fetchPlan>
        <loader/>
    </instance>
</data>
<facets>
    <dataLoadCoordinator auto="true"/>
</facets>
<actions>
    <action id="saveAction" type="detail_saveClose"/>
    <action id="closeAction" type="detail_close"/>
</actions>
<layout>
    <formLayout id="form" dataContainer="gdExchangeRateDc">
        <select id="rateTypeField" property="rateType"/>
        <entityComboBox id="ccyPairIdField" property="ccyPairId" itemsContainer="gdCurrencyPairDc" allowCustomValue="false" required="true"/>
        <multiSelectComboBox id="ccy1ParValueIdField" property="ccy1ParValueId" required="true" itemsContainer="cmParValueDc" allowCustomValue="false"/>
        <entityComboBox id="ccyIdField" property="ccyId" itemsContainer="gdCurrencyDc" allowCustomValue="false" visible="false"/>
        <bigDecimalField id="buyRateCashField" property="buyRateCash">
            <validators>
                <digits integer="20"
                        fraction="8"
                        message="Tỷ giá mua tiền mặt không thỏa mãn ${fraction} chữ số thập phân sau dấu phẩy hoặc ${integer} chữ số thập phân trước dấu phẩy"/>
                <positive message="Tỷ giá mua tiền mặt phải > 0"/>
            </validators>
        </bigDecimalField>
        <bigDecimalField id="sellRateCashField" property="sellRateCash">
            <validators>
                <digits integer="20"
                        fraction="8"
                        message="Tỷ giá bán tiền mặt không thỏa mãn ${fraction} chữ số thập phân sau dấu phẩy hoặc ${integer} chữ số thập phân trước dấu phẩy"/>
                <positive message="Tỷ giá bán tiền mặt phải > 0"/>
            </validators>
        </bigDecimalField>
        <bigDecimalField id="buyRateTransferField" property="buyRateTransfer" required="true">
            <validators>
                <digits integer="20"
                        fraction="8"
                        message="Tỷ giá mua chuyển khoản không thỏa mãn ${fraction} chữ số thập phân sau dấu phẩy hoặc ${integer} chữ số thập phân trước dấu phẩy"/>
                <positive message="Tỷ giá mua chuyển khoản phải > 0"/>
            </validators>
        </bigDecimalField>
        <bigDecimalField id="sellRateTransferField" property="sellRateTransfer" required="true">
            <validators>
                <digits integer="20"
                        fraction="8"
                        message="Tỷ giá bán chuyển khoản không thỏa mãn ${fraction} chữ số thập phân sau dấu phẩy hoặc ${integer} chữ số thập phân trước dấu phẩy"/>
                <positive message="Tỷ giá bán chuyển khoản phải > 0"/>
            </validators>
        </bigDecimalField>

        <datePicker id="effectDateField" property="effectDate">
            <validators>
                <futureOrPresent message="Ngày hiệu lực phải >= ngày hiện tại của hệ thống"/>
            </validators>
        </datePicker>
        <timePicker id="effectTimeField" property="effectTime"/>
        <textField id="descriptionField" property="description"/>

    </formLayout>
    <hbox id="detailActions">
        <button id="saveAndCloseBtn" action="saveAction"/>
        <button id="closeBtn" action="closeAction"/>
    </hbox>
</layout>
''' 4. Web ![image|690x207](upload://wixKriM7CG03nRrKRJ6rHBWTUuX.png) 5. Error ''' java.lang.RuntimeException: Error subscribe ComponentEventListener listener method invocation at io.jmix.flowui.sys.ViewControllerDependencyInjector.lambda$getComponentEventListener$626afb77$1(ViewControllerDependencyInjector.java:530) ~[jmix-flowui-2.1.0.jar:na] at com.vaadin.flow.component.ComponentEventBus.fireEventForListener(ComponentEventBus.java:233) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.component.ComponentEventBus.fireEvent(ComponentEventBus.java:222) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.component.Component.fireEvent(Component.java:411) ~[flow-server-24.1.12.jar:24.1.12] at io.jmix.flowui.view.StandardDetailView.saveChanges(StandardDetailView.java:212) ~[jmix-flowui-2.1.0.jar:na] at io.jmix.flowui.view.StandardDetailView.closeWithSave(StandardDetailView.java:292) ~[jmix-flowui-2.1.0.jar:na] at io.jmix.flowui.action.view.DetailSaveCloseAction.execute(DetailSaveCloseAction.java:66) ~[jmix-flowui-2.1.0.jar:na] at io.jmix.flowui.action.view.ViewAction.actionPerform(ViewAction.java:140) ~[jmix-flowui-2.1.0.jar:na] at io.jmix.flowui.kit.component.button.JmixButtonActionSupport.onButtonClick(JmixButtonActionSupport.java:159) ~[jmix-flowui-kit-2.1.0.jar:na] at com.vaadin.flow.component.ComponentEventBus.fireEventForListener(ComponentEventBus.java:233) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.component.ComponentEventBus.handleDomEvent(ComponentEventBus.java:475) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.component.ComponentEventBus.lambda$addDomTrigger$dd1b7957$1(ComponentEventBus.java:292) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.internal.nodefeature.ElementListenerMap.lambda$fireEvent$2(ElementListenerMap.java:447) ~[flow-server-24.1.12.jar:24.1.12] at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na] at com.vaadin.flow.internal.nodefeature.ElementListenerMap.fireEvent(ElementListenerMap.java:447) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.communication.rpc.EventRpcHandler.handleNode(EventRpcHandler.java:62) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.communication.rpc.AbstractRpcInvocationHandler.handle(AbstractRpcInvocationHandler.java:74) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocationData(ServerRpcHandler.java:459) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.communication.ServerRpcHandler.lambda$handleInvocations$2(ServerRpcHandler.java:440) ~[flow-server-24.1.12.jar:24.1.12] at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na] at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:440) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:323) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:114) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1529) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:398) ~[flow-server-24.1.12.jar:24.1.12] at com.vaadin.flow.spring.SpringServlet.service(SpringServlet.java:106) ~[vaadin-spring-24.1.12.jar:na] at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614) ~[jakarta.servlet-api-6.0.0.jar:6.0.0] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:642) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:408) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:313) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:277) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.springframework.web.servlet.mvc.ServletForwardingController.handleRequestInternal(ServletForwardingController.java:141) ~[spring-webmvc-6.0.12.jar:6.0.12] at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:178) ~[spring-webmvc-6.0.12.jar:6.0.12] at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:51) ~[spring-webmvc-6.0.12.jar:6.0.12] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081) ~[spring-webmvc-6.0.12.jar:6.0.12] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974) ~[spring-webmvc-6.0.12.jar:6.0.12] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) ~[spring-webmvc-6.0.12.jar:6.0.12] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914) ~[spring-webmvc-6.0.12.jar:6.0.12] at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:547) ~[jakarta.servlet-api-6.0.0.jar:6.0.0] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) ~[spring-webmvc-6.0.12.jar:6.0.12] at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614) ~[jakarta.servlet-api-6.0.0.jar:6.0.0] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at io.jmix.core.impl.logging.LogMdcFilter.doFilterInternal(LogMdcFilter.java:28) ~[jmix-core-2.1.0.jar:na] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.springframework.security.web.FilterChainProxy.lambda$doFilterInternal$3(FilterChainProxy.java:231) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:365) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.access.intercept.AuthorizationFilter.doFilter(AuthorizationFilter.java:100) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:126) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:120) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:131) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:85) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:100) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:110) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:101) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:179) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:151) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:129) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:227) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:221) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:107) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:93) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:117) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:117) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:62) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:233) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:191) ~[spring-security-web-6.1.4.jar:6.1.4] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:352) ~[spring-web-6.0.12.jar:6.0.12] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:268) ~[spring-web-6.0.12.jar:6.0.12] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-6.0.12.jar:6.0.12] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-6.0.12.jar:6.0.12] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-6.0.12.jar:6.0.12] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1740) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-10.1.13.jar:10.1.13] at java.base/java.lang.Thread.run(Thread.java:840) ~[na:na] Caused by: java.lang.IllegalStateException: Cannot get unfetched attribute [ccy1ParValueId] from detached object com.fis.pbcapcore.entity.GdExchangeRate-2702 [detached]. at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.throwUnfetchedAttributeException(UnitOfWorkValueHolder.java:337) ~[org.eclipse.persistence.core-4.0.1-15-jmix.jar:na] at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:111) ~[org.eclipse.persistence.core-4.0.1-15-jmix.jar:na] at org.eclipse.persistence.indirection.IndirectSet.buildDelegate(IndirectSet.java:223) ~[org.eclipse.persistence.core-4.0.1-15-jmix.jar:na] at org.eclipse.persistence.indirection.IndirectSet.getDelegate(IndirectSet.java:413) ~[org.eclipse.persistence.core-4.0.1-15-jmix.jar:na] at org.eclipse.persistence.indirection.IndirectSet.contains(IndirectSet.java:346) ~[org.eclipse.persistence.core-4.0.1-15-jmix.jar:na] at java.base/java.util.Collections.disjoint(Collections.java:5584) ~[na:na] at com.fis.pbcapcore.view.gdexchangerate.GdExchangeRateDetailView.onBeforeSave(GdExchangeRateDetailView.java:231) ~[main/:na] at io.jmix.flowui.sys.ViewControllerDependencyInjector.lambda$getComponentEventListener$626afb77$1(ViewControllerDependencyInjector.java:528) ~[jmix-flowui-2.1.0.jar:na] ... 130 common frames omitted ''' 6. Code ''' @Subscribe public void onBeforeSave(final BeforeSaveEvent event) { getEditedEntity().setApproveStatus(ApproveStatus.WAITFORAPPROVE); getEditedEntity().setDeleted(YesNo.NO); getEditedEntity().setCcyId(getEditedEntity().getCcyPairId().getCcy1Id()); Set cmParValueSet = ccy1ParValueIdField.getValue();
    if (rateTypeField.getValue().equals(RateType.TRANSFER)) {
        getEditedEntity().setBuyRateCash(null);
        getEditedEntity().setSellRateCash(null);
        getEditedEntity().setCcy1ParValueId(null);
    } else if (rateTypeField.getValue().equals(RateType.CASH)) {
        getEditedEntity().setBuyRateTransfer(null);
        getEditedEntity().setSellRateTransfer(null);
    }

    if (entityStates.isNew(getEditedEntity()) && getEditedEntity().getRateType().equals(RateType.CASH)) {
        Integer count = dataManager.loadValue("select count(e) from GdExchangeRate e where e.deleted = 'N' and e.ccyPairId = :ccyPairId and e.rateType = :rateType and e.effectDate = :effectDate and e.effectTime = :effectTime", Integer.class)
                .parameter("ccyPairId", getEditedEntity().getCcyPairId())
                .parameter("rateType", getEditedEntity().getRateType())
                .parameter("effectDate", getEditedEntity().getEffectDate())
                .parameter("effectTime", getEditedEntity().getEffectTime())
                .one();
        if (count > 0) {
            List<GdExchangeRate> gdExchangeRateList = dataManager.loadValue("select e from GdExchangeRate e where e.deleted = 'N' and e.ccyPairId = :ccyPairId and e.rateType = :rateType and e.effectDate = :effectDate and e.effectTime = :effectTime and e.id <> :id", GdExchangeRate.class)
                    .parameter("ccyPairId", getEditedEntity().getCcyPairId())
                    .parameter("rateType", getEditedEntity().getRateType())
                    .parameter("effectDate", getEditedEntity().getEffectDate())
                    .parameter("effectTime", getEditedEntity().getEffectTime())
                    .parameter("id", getEditedEntity().getId())
                    .list();

            for (GdExchangeRate gdExchangeRate : gdExchangeRateList) {
                if(!Collections.disjoint(gdExchangeRate.getCcy1ParValueId(),cmParValueSet)) {
                    throw new ValidationException(messageBundle.getMessage("22000014"));
                }
            }
        }
    }

    if (entityStates.isNew(getEditedEntity()) && getEditedEntity().getRateType().equals(RateType.TRANSFER)) {
        Integer count = dataManager.loadValue("select count(e) from GdExchangeRate e where e.deleted = 'N' and e.ccyPairId = :ccyPairId and e.rateType = :rateType and e.effectDate = :effectDate and e.effectTime = :effectTime", Integer.class)
                .parameter("ccyPairId", getEditedEntity().getCcyPairId())
                .parameter("rateType", getEditedEntity().getRateType())
                .parameter("effectDate", getEditedEntity().getEffectDate())
                .parameter("effectTime", getEditedEntity().getEffectTime())
                .one();

        if (count > 0) {
            throw new ValidationException(messageBundle.getMessage("22000014"));
        }
    }

    if (!entityStates.isNew(getEditedEntity())) {
        Integer count = dataManager.loadValue("select count(e) from GdExchangeRate e where e.deleted = 'N' and e.ccyPairId = :ccyPairId and e.rateType = :rateType and e.effectDate = :effectDate and e.effectTime = :effectTime and e.id <> :id", Integer.class)
                .parameter("ccyPairId", getEditedEntity().getCcyPairId())
                .parameter("rateType", getEditedEntity().getRateType())
                .parameter("effectDate", getEditedEntity().getEffectDate())
                .parameter("effectTime", getEditedEntity().getEffectTime())
                .parameter("id", getEditedEntity().getId())
                .one();

        if (count > 0) {
            throw new ValidationException(messageBundle.getMessage("22000014"));
        }
    }
}

‘’’

Hi @anhnct.work

We would appreciate it very much if you reproduce the issue on a small test project based on the latest Jmix 2.1.2.
Also, please format your code and long output using triple backquotes (```).

Regards,
Konstantin