Spring Data 的 @DomainEvents
与 AbstractAggregateRoot
工作很好,但失败了 repository.save(Iterable<S> entities)
在使用它的域对象上。
错误跟踪如下:-
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:216)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:201)
at org.springframework.data.repository.core.support.EventPublishingRepositoryProxyPostProcessor$EventPublishingMethod.publishEventsFrom(EventPublishingRepositoryProxyPostProcessor.java:173)
at org.springframework.data.repository.core.support.EventPublishingRepositoryProxyPostProcessor$EventPublishingMethodInterceptor.invoke(EventPublishingRepositoryProxyPostProcessor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
at org.springframework.aop.framework.
此问题是由 clearDomainEvents(…)
引起的根据 EventPublishingRepositoryProxyPostProcessor
中的以下代码应用于上述情况
if (clearingMethod != null) {
ReflectionUtils.invokeMethod(clearingMethod, object);
}
如果这个问题能够得到解决,那就太好了,或者我在这里遗漏了一些东西。
最佳答案
您似乎遇到了DATACMNS-1067 ,已通过 Ingalls SR4 发布列车修复。请确保升级到此版本或(推荐)到最新版本,当前为 Ingalls SR7。
关于java - Spring Data @DomainEvents 与 AbstractAggregateRoot 保存失败(List <S> iterables),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46415844/