我需要通过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(。 我怎么能这样做?
好的)这里Stack Trace
> 2017-03-08 11:48:00.548 ERROR 4548 --- [nio-8080-exec-1] > o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for > servlet [dispatcherServlet] in context with path [] threw exception > [Request processing failed; nested exception is > java.lang.NullPointerException] with root cause > 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) > ~[classes/:na] at > com.spring.dao.impl.OrderDetailsDAOImpl$$FastClassBySpringCGLIB$$38c0db60.invoke() > ~[classes/:na] at > 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() > ~[classes/:na] at > com.spring.service.impl.OrderServiceImpl.getOrder(OrderServiceImpl.java:78) > ~[classes/:na] at > com.spring.service.impl.OrderServiceImpl$$FastClassBySpringCGLIB$$7d1c6228.invoke() > ~[classes/:na] at > 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$$d51254c.getOrder() > ~[classes/:na] at > com.spring.web.WaitersController.getOrderDetails(WaitersController.java:61) > ~[classes/:na] at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > ~[na:1.8.0_111] at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > ~[na:1.8.0_111] at > 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] at > 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]
答案 0 :(得分:1)
您正在获取NullPointerException
,因为您要求Envers查询API查找Order
实体的修订版本,您未将其指定为已审核。
我已经提交了一个JIRA问题HHH-11558来解决这个问题,并提出了更为积极的回应。
如果Order
已经审核了,它就会按预期运作。