Spring Data的@DomainEvents
与AbstractAggregateRoot
工作很好,但在其使用的域对象上失败repository.save(Iterable<S> entities)
。Spring Data @DomainEvents和AbstractAggregateRoot保存失败(列表<S>迭代)
的错误跟踪如下: -
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);
}
如果将是巨大的这可以解决或我在这里错过了一些东西。
你试过调试吗? – emotionlessbananas
烨试图试图调用对象的clearDomainEvents方法在保存(迭代)的情况下是一个列表,发布它的事件处理,但clearDomainEvents以及它应该把逻辑。 –
如果我理解正确,即使您的事件处理代码为空,也会得到此异常?如果是这种情况,请提交错误。 –