>我需要通过EmbeddedId的属性进行修订。但我不知道怎么做。
@Entity
@javax.persistence.Table(name = "orders_details")
@Audited
public class OrderDetail implements Serializable {
@EmbeddedId
private OrderDetailsId id;
@Embeddable
public class OrderDetailsId implements Serializable {
@Basic
@Column(name = "product_name")
private String prodName;
@Basic
@ManyToOne
@JoinColumn(name = "order_id")
private Order order;
AuditReader auditReader = AuditReaderFactory.get(em);
List list = auditReader.createQuery().forRevisionsOfEntity(Order.class, false, false).
add(AuditEntity.property("id.order").eq(id)).getResultList();
GetResultList 抛出 NullPointer (. 我该怎么做?
好的)此处堆栈跟踪
> 2017-03-08 11:48:00.548 错误 4548 --- [NIO-8080-exec-1] >[/].[dispatcherServlet] : Servlet.service() for > Servlet [dispatcherServlet] 在具有路径 [] 的上下文中抛出异常 > [请求处理失败;嵌套异常为 > java.lang.NullPointerException] 与根本原因 >java.lang.NullPointerException: null at org.hibernate.envers.internal.entities.EntitiesConfigurations.getRelationDescription(EntitiesConfigurations.java:98) > ~[hibernate-envers-5.0.11.Final.jar:5.0.11.Final] at > org.hibernate.envers.query.criteria.internal.CriteriaTools.getRelatedEntity(CriteriaTools.java:44) > ~[hibernate-envers-5.0.11.Final.jar:5.0.11.Final] at > org.hibernate.envers.query.criteria.internal.SimpleAuditExpression.addToQuery(SimpleAuditExpression.java:45) > ~[hibernate-envers-5.0.11.Final.jar:5.0.11.Final] at > org.hibernate.envers.query.internal.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:89) > ~[hibernate-envers-5.0.11.Final.jar:5.0.11.Final] at > org.hibernate.envers.query.internal.impl.AbstractAuditQuery.getResultList(AbstractAuditQuery.java:93) > ~[hibernate-envers-5.0.11.Final.jar:5.0.11.Final] at > com.spring.dao.impl.OrderDetailsDAOImpl.getRevision(OrderDetailsDAOImpl.java:52) > ~[类/:na] 在 > com.spring.dao.impl.OrderDetailsDAOImpl$$FastClassBySpringCGLIB$$38c0db60.invoke() > ~[类/:na] 在 > org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) > ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721) > ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) > ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) > ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) > ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656) > ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > com.spring.dao.impl.OrderDetailsDAOImpl$$EnhancerBySpringCGLIB$$6146d8cb.getRevision() > ~[类/:na] 在 > com.spring.service.impl.OrderServiceImpl.getOrder(OrderServiceImpl.java:78) > ~[类/:na] 在 > com.spring.service.impl.OrderServiceImpl$$FastClassBySpringCGLIB$$7d1c6228.invoke() > ~[类/:na] 在 > org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) > ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721) > ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) > ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) > ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) > ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) > ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) > ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656) > ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > com.spring.service.impl.OrderServiceImpl$$EnhancerBySpringCGLIB$$d 51254c.getOrder() > ~[类/:na] 在 > com.spring.web.WaitersController.getOrderDetails(WaitersController.java:61) > ~[类/:na] 在 > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > ~[na:1.8.0_111] 在 > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > ~[na:1.8.0_111] 在 > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)> ~[na:1.8.0_111] at java.lang.reflect.Method.invoke(Method.java:498) > ~[na:1.8.0_111] 在 > org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > javax.servlet.http.HttpServlet.service(HttpServlet.java:622) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) > ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > javax.servlet.http.HttpServlet.service(HttpServlet.java:729) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) > ~[tomcat-embed-websocket-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)> ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) > ~[spring-security-web-4.2.1.RELEASE.jar:4.2.1.RELEASE] at > org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) > ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE] at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) > ~[Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > [na:1.8.0_111] at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > [na:1.8.0_111] at > org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) > [Tomcat-embed-core-8.5.11.jar:8.5.11] at > java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
您获得NullPointerException
是因为您要求 Envers 查询 API 查找Order
实体的修订,您未将其指定为正在审核。
我已经提交了JIRA问题HHH-11558,以更微不足道的答复来解决这个问题。
如果Order
经过审计,它就会按预期工作。