2014-01-15 71 views
0

我想堅持一個類時出現問題...支持顯示java.lang.NullPointerException:空實體不受org.hibernate.event.def.EventCache

休眠拋出此異常:

Root cause: 

java.lang.NullPointerException: null entities are not supported by org.hibernate.event.def.EventCache 
at org.hibernate.event.def.EventCache.containsKey(EventCache.java:80) 
at org.hibernate.event.def.DefaultMergeEventListener.mergeTransientEntity(DefaultMergeEventListener.java:361) 
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:303) 
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:258) 
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84) 
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:867) 
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:851) 
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:855) 
at com.mycompany.myapp.service.data.DataServiceBean.merge(DataServiceBean.java:1337) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
at $Proxy64.merge(Unknown Source) 
at com.mycompany.myapp.web.base.BaseForm.store(BaseForm.java:991) 
at com.mycompany.myapp.web.base.BaseForm.store(BaseForm.java:942) 
at com.mycompany.myapp.web.forms.therapie.TherapieForm.onSaveFormData(TherapieForm.java:591) 
at com.mycompany.myapp.web.base.BaseForm.doSave(BaseForm.java:370) 
at com.mycompany.myapp.web.base.BaseForm.saveAndTrigger(BaseForm.java:1137) 
at com.mycompany.myapp.web.forms.reason.GrundEingabeForm$5.onSubmit(GrundEingabeForm.java:302) 
at com.mycompany.myapp.web.comp.MyAppAjaxButton$1.onSubmit(MyAppAjaxButton.java:65) 
at com.mycompany.myapp.web.comp.MyAppAjaxFormSubmitBehavior.onEvent(MyAppAjaxFormSubmitBehavior.java:151) 
at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177) 
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:286) 
at org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:119) 
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92) 
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250) 
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) 
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) 
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) 
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479) 
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312) 
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139) 
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113) 
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139) 
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:378) 
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) 
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) 
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417) 
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
at org.mortbay.jetty.Server.handle(Server.java:324) 
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535) 
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880) 
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747) 
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) 
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) 
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) 
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520) 

起初,Therapie類的屬性在數據庫中不能爲null,我認爲這個異常是因爲該屬性爲null而拋出的......但我擺脫了數據庫上的約束(現在該屬性是可空的),並且當該屬性在被保存點處沒有值時異常繼續被拋出。

如果屬性不是null(它有一個設置值),則沒有拋出異常,但如果它沒有價值(爲空),則拋出異常......

發生了什麼?

+0

的[什麼空的實體,不支持可能重複由org.hibernate.event.def.EventCache是​​什麼意思?](http://stackoverflow.com/questions/13829157/what-does-null-entities-are-not-supported-by-org-hibernate-event-def- eventcache) – eltabo

+0

不可以,因爲這個問題的解決方案是我嘗試過的並且不起作用。該屬性在代碼和數據庫中都是可空的。 – diminuta

回答

1

好了,下課了延伸的另一一個有getWeight()方法標記爲不可選的...所以我只是啞巴....

相關問題