我为什么在使用neo4j OGM时得到’Error mapping GraphModel’错误。

huangapple go评论107阅读模式
英文:

Why I'm getting 'Error mapping GraphModel' error with neo4j OGM

问题

以下是要翻译的代码部分:

  1. I am using a server cluster structure with 1 LEADER and 2 FOLLOWERS.
  2. Nodes structure
    我为什么在使用neo4j OGM时得到’Error mapping GraphModel’错误。

Save Payout method:

  1. @Override
  2. @UseBookmark
  3. @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  4. public void addEmploymentPayout(EmploymentPayoutDTO payoutDto, String employmentId) {
  5. try {
  6. // Map
  7. var payout = dozerMapper.map(payoutDto, EmploymentPayout.class);
  8. // Save
  9. var employment = profileService.findEmploymentByUuid(employmentId);
  10. var container = employmentPayoutContainerRepository.getContainerIfExist(employmentId)
  11. .orElse(new EmploymentPayoutContainer());
  12. container.setEmployment(employment);
  13. var payouts = Optional.ofNullable(container.getEmploymentPayouts())
  14. .orElse(new ArrayList<>());
  15. payouts.add(payout);
  16. container.setEmploymentPayouts(payouts);
  17. employmentPayoutContainerRepository.save(container);
  18. // employmentPayout.setEmploymentPayoutContainer(container);
  19. // employmentPayoutRepository.save(payout);
  20. // employmentPayoutRepository.save(employmentPayout, 2);
  21. } catch (Exception e) {
  22. LOG.error(ExceptionUtils.getStackTrace(e));
  23. }
  24. }

Method getAllPureEmploymentsByProfileId:

  1. @Query("MATCH (p:Profile) WHERE p.uuid=$profileId "
  2. + "MATCH (p)-[:HAS_PROFILE_EMPLOYMENT_CONTAINER]->(pec:ProfileEmploymentContainer) "
  3. + "MATCH path = (pec)-[:USES_PROFILE_EMPLOYMENT]-(pe:ProfileEmployment) RETURN pec, path")
  4. ProfileEmploymentContainer getAllPureEmploymentsByProfileId( @Param("profileId") String profileId);

希望这些信息对你有所帮助。如果你有任何其他问题,请随时提出。

英文:

Inputs:

  1. I am using a server cluster structure with 1 LEADER and 2 FOLLOWERS.
  2. Nodes structure
    我为什么在使用neo4j OGM时得到’Error mapping GraphModel’错误。

Save Payout method:

  1. @Override
  2. @UseBookmark
  3. @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  4. public void addEmploymentPayout(EmploymentPayoutDTO payoutDto, String employmentId) {
  5. try {
  6. // Map
  7. var payout = dozerMapper.map(payoutDto, EmploymentPayout.class);
  8. // Save
  9. var employment = profileService.findEmploymentByUuid(employmentId);
  10. var container = employmentPayoutContainerRepository.getContainerIfExist(employmentId)
  11. .orElse(new EmploymentPayoutContainer());
  12. container.setEmployment(employment);
  13. var payouts = Optional.ofNullable(container.getEmploymentPayouts())
  14. .orElse(new ArrayList<>());
  15. payouts.add(payout);
  16. container.setEmploymentPayouts(payouts);
  17. employmentPayoutContainerRepository.save(container);
  18. // employmentPayout.setEmploymentPayoutContainer(container);
  19. // employmentPayoutRepository.save(payout);
  20. // employmentPayoutRepository.save(employmentPayout, 2);
  21. } catch (Exception e) {
  22. LOG.error(ExceptionUtils.getStackTrace(e));
  23. }
  24. }

Method getAllPureEmploymentsByProfileId:

  1. @Query("MATCH (p:Profile) WHERE p.uuid=$profileId "
  2. + "MATCH (p)-[:HAS_PROFILE_EMPLOYMENT_CONTAINER]->(pec:ProfileEmploymentContainer) "
  3. + "MATCH path = (pec)-[:USES_PROFILE_EMPLOYMENT]-(pe:ProfileEmployment) RETURN pec, path")
  4. ProfileEmploymentContainer getAllPureEmploymentsByProfileId( @Param("profileId") String profileId);

Description

After saving (adding) a new EmploymentPayout (addEmploymentPayout), when I try to load all or part of the path (getAllPureEmploymentsByProfileId), I get this error. But the error disappears after restarting the server.
Can you help me understand what I am doing wrong? Thanks a lot!

Error:

  1. org.springframework.dao.InvalidDataAccessApiUsageException: Error mapping GraphModel; nested exception is org.neo4j.ogm.exception.core.MappingException: Error mapping GraphModel
  2. at org.springframework.data.neo4j.transaction.SessionFactoryUtils.convertOgmAccessException(SessionFactoryUtils.java:125)
  3. at org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator.translateExceptionIfPossible(Neo4jPersistenceExceptionTranslator.java:31)
  4. at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
  5. at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
  6. at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152)
  7. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  8. at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
  9. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  10. at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
  11. at com.sun.proxy.$Proxy128.getAllPureEmploymentsByProfileId(Unknown Source)
  12. at com.infotemp.neo4j.service.impl.ProfileServiceImpl.getEmploymentsForUser(ProfileServiceImpl.java:7410)
  13. at com.infotemp.neo4j.service.impl.ProfileServiceImpl$$FastClassBySpringCGLIB$$9ac11082.invoke(<generated>)
  14. at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
  15. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783)
  16. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  17. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
  18. at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
  19. at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
  20. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
  21. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  22. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
  23. at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
  24. at com.infotemp.neo4j.service.impl.ProfileServiceImpl$$EnhancerBySpringCGLIB$$56efb754.getEmploymentsForUser(<generated>)
  25. at com.infotemp.neo4j.service.impl.VacationCompensationAccountServiceImpl.getProfileEmployments(VacationCompensationAccountServiceImpl.java:536)
  26. at com.infotemp.neo4j.service.impl.VacationCompensationAccountServiceImpl.getCurrentEmployment(VacationCompensationAccountServiceImpl.java:73)
  27. at com.infotemp.neo4j.service.impl.VacationCompensationAccountServiceImpl$$FastClassBySpringCGLIB$$18090ab5.invoke(<generated>)
  28. at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
  29. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783)
  30. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  31. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
  32. at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
  33. at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
  34. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
  35. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  36. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
  37. at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
  38. at com.infotemp.neo4j.service.impl.VacationCompensationAccountServiceImpl$$EnhancerBySpringCGLIB$$5ea6899a.getCurrentEmployment(<generated>)
  39. at com.infotemp.controller.ProfileController.getVacationCompansation(ProfileController.java:2096)
  40. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  41. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  42. at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  43. at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  44. at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
  45. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
  46. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
  47. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
  48. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
  49. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  50. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
  51. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
  52. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
  53. at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
  54. at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
  55. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
  56. at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
  57. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
  58. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  59. at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  60. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  61. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  62. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327)
  63. at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
  64. at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81)
  65. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  66. at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122)
  67. at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116)
  68. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  69. at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126)
  70. at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81)
  71. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  72. at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:109)
  73. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  74. at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149)
  75. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  76. at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
  77. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  78. at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:182)
  79. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  80. at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)
  81. at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)
  82. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  83. at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
  84. at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
  85. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
  86. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  87. at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110)
  88. at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)
  89. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  90. at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)
  91. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
  92. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)
  93. at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211)
  94. at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183)
  95. at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354)
  96. at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267)
  97. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  98. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  99. at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
  100. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
  101. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  102. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  103. at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
  104. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
  105. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  106. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  107. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
  108. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
  109. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  110. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  111. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
  112. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
  113. at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
  114. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
  115. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
  116. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
  117. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:359)
  118. at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
  119. at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
  120. at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889)
  121. at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1735)
  122. at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  123. at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
  124. at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
  125. at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  126. at java.base/java.lang.Thread.run(Thread.java:829)
  127. Caused by: org.neo4j.ogm.exception.core.MappingException: Error mapping GraphModel
  128. at org.neo4j.ogm.context.GraphEntityMapper.mapContentOf(GraphEntityMapper.java:164)
  129. at org.neo4j.ogm.context.GraphEntityMapper.lambda$map$2(GraphEntityMapper.java:115)
  130. at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
  131. at org.neo4j.ogm.context.GraphEntityMapper.map(GraphEntityMapper.java:117)
  132. at org.neo4j.ogm.context.GraphRowModelMapper.map(GraphRowModelMapper.java:60)
  133. at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.lambda$executeAndMap$1(ExecuteQueriesDelegate.java:165)
  134. at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:590)
  135. at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:564)
  136. at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.executeAndMap(ExecuteQueriesDelegate.java:150)
  137. at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:117)
  138. at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:425)
  139. at jdk.internal.reflect.GeneratedMethodAccessor114.invoke(Unknown Source)
  140. at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  141. at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  142. at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
  143. at org.springframework.data.neo4j.transaction.SharedSessionCreator$SharedSessionInvocationHandler.lambda$invoke$1(SharedSessionCreator.java:121)
  144. at org.springframework.data.neo4j.transaction.SharedSessionCreator$SharedSessionInvocationHandler.invokeInTransaction(SharedSessionCreator.java:159)
  145. at org.springframework.data.neo4j.transaction.SharedSessionCreator$SharedSessionInvocationHandler.invoke(SharedSessionCreator.java:123)
  146. at com.sun.proxy.$Proxy89.query(Unknown Source)
  147. at org.springframework.data.neo4j.repository.query.GraphQueryExecution$SingleEntityExecution.execute(GraphQueryExecution.java:68)
  148. at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.doExecute(GraphRepositoryQuery.java:76)
  149. at org.springframework.data.neo4j.repository.query.AbstractGraphRepositoryQuery.execute(AbstractGraphRepositoryQuery.java:57)
  150. at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195)
  151. at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152)
  152. at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130)
  153. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  154. at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
  155. at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
  156. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
  157. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  158. at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
  159. ... 120 more
  160. Caused by: java.lang.NullPointerException
  161. at org.neo4j.ogm.session.Utils.coerceTypes(Utils.java:79)
  162. at org.neo4j.ogm.metadata.FieldInfo.write(FieldInfo.java:449)
  163. at org.neo4j.ogm.context.GraphEntityMapper.createRelationshipEntity(GraphEntityMapper.java:419)
  164. at org.neo4j.ogm.context.GraphEntityMapper.mapRelationshipEntity(GraphEntityMapper.java:354)
  165. at org.neo4j.ogm.context.GraphEntityMapper.mapRelationships(GraphEntityMapper.java:330)
  166. at org.neo4j.ogm.context.GraphEntityMapper.mapContentOf(GraphEntityMapper.java:158)
  167. ... 150 more

I tried to add these annotations but it didn't help:

  • @UseBookmark
  • @Transactional(rollbackFor = Exception.class,
    propagation = Propagation.REQUIRED)

UPD

I don't have that problem with standalone (no clusters) Neoj4 server.

答案1

得分: 1

I found out what caused this problem. It was the call of this asynchronous method:

  1. emailService.sendPayoutCreatedEmailAsync(employmentId, payout, userDetails); // fire-and-forget

The method above is called just after the addEmploymentPayout one.

This is a definition of this method which is called another non-ansync method - sendPayoutCreatedEmail (this method has calls to repository methods):

  1. @Override
  2. public CompletableFuture<Void> sendPayoutCreatedEmailAsync(String employmentId, EmploymentPayoutDTO payout, InfotempUserDetails userDetails) {
  3. var future = CompletableFuture.runAsync(() -> {
  4. this.sendPayoutCreatedEmail(employmentId, payout, userDetails);
  5. });
  6. return future;
  7. }

SOLUTION:

It works (don't know how, but it does) if you change the asynchronous method call to a call from a new thread. Like this:

  1. new Thread(() -> {
  2. emailService.sendPayoutCreatedEmail(employmentId, payout, userDetails);
  3. }).start();
英文:

I found out what caused this problem. It was the call of this asynchronous method:

  1. emailService.sendPayoutCreatedEmailAsync(employmentId, payout, userDetails); // fire-and-forget

The method above is called just after the addEmploymentPayout one.

This is a definition of this method which is called another non-ansync method - sendPayoutCreatedEmail (this method has calls to repository methods):

  1. @Override
  2. public CompletableFuture&lt;Void&gt; sendPayoutCreatedEmailAsync(String employmentId, EmploymentPayoutDTO payout, InfotempUserDetails userDetails) {
  3. var future = CompletableFuture.runAsync(() -&gt; {
  4. this.sendPayoutCreatedEmail(employmentId, payout, userDetails);
  5. });
  6. return future;
  7. }

SOLUTION:

It works (don't know how, but it does) if you change the asynchronous method call to a call from a new thread. Like this:

  1. new Thread(() -&gt; {
  2. emailService.sendPayoutCreatedEmail(employmentId, payout, userDetails);
  3. }).start();

huangapple
  • 本文由 发表于 2023年7月4日 23:38:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76614144.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定