what does null entities are not supported by org.hibernate.event.def.EventCache mean?

蓝咒 提交于 2019-12-13 14:41:03

问题


I am getting the error at the point I try to save an entity. I only get this error when I have booted up my server, not when I run my unit tests using dbunit.

I am trying to save an association. My unit test should be the exact same condition as that which I am encountering when manually testing. I am adding a new entity on one end of the relationship where no relationships existed before.

I am using HSQLDB with the unit tests and the web app is using SQL Server.

The searches I have performed have not proved fruitful. An explanation of the message would prove very useful.

Here is the test case (that works just fine!):

    @Test
      @DatabaseSetup(value="MobileWebsiteTest.saveMobilewebsiteMobilecolorswatchmapuserdefined_NewUserSwatch.xml", type=DatabaseOperation.REFRESH)
    public void saveMobilewebsiteMobilecolorswatchmapuserdefined_NewUserSwatch() {
        // given
        Integer mobileWebsiteId = 569;
        Mobilecolorswatchmapuserdefined expected = MobilecolorswatchmapuserdefinedBuilder.init().build();

        // when
        Mobilewebsite result = service.saveMobilewebsiteMobilecolorswatchmapuserdefined(mobileWebsiteId, expected);

        // then
        assertNotNull("The Mobilewebsite user defined swatch should not be null", result.getMobilecolorswatchmapuserdefined());
        assertNotNull("The Mobilewebsite user defined swatch id should not be null.", result.getMobilecolorswatchmapuserdefined().getMobileColorSwatchMapUserDefinedId());
        assertEquals("The result aside property should be equivalent to the expected aside property.", expected.getAside(), result.getMobilecolorswatchmapuserdefined().getAside());
        assertEquals("The result SiteName property should be equivalent to the expected SiteName property.", expected.getSiteName(), result.getMobilecolorswatchmapuserdefined().getSiteName());
    }

Here is the service (note: I am currently doing a delete/save under the condition that there is already an association - this should be one-to-one, but is legacy):

@Override
@Transactional
public Mobilewebsite saveMobilewebsiteMobilecolorswatchmapuserdefined(Integer mobileWebsiteId, Mobilecolorswatchmapuserdefined related_swatchmap) {
    log.debug("saveMobilewebsiteMobilecolorswatchmapuserdefined(Integer mobileWebsiteId=[" + mobileWebsiteId + "],  Mobilecolorswatchmapuserdefined related_swatchmap=[" + related_swatchmap + "])");

    Mobilewebsite mobilewebsite = mobilewebsiteDAO.findMobilewebsiteByPrimaryKey(mobileWebsiteId, -1, -1);
    Calendar now = Calendar.getInstance();

    if (mobilewebsite.getMobilecolorswatchmapuserdefined() != null) {
        this.deleteMobilewebsiteMobilecolorswatchmapuserdefined(mobilewebsite.getMobileWebsiteId(), mobilewebsite.getMobilecolorswatchmapuserdefined().getMobileColorSwatchMapUserDefinedId());
    }

    related_swatchmap.setCreatedDtstamp(now);
    related_swatchmap.setLastUpdatedDtstamp(now);

    related_swatchmap.addToMobilewebsites(mobilewebsite);
    **related_swatchmap = mobilecolorswatchmapuserdefinedDAO.store(related_swatchmap);**

    mobilewebsite.setMobilecolorswatchmapuserdefined(related_swatchmap);
    mobilewebsite = mobilewebsiteDAO.store(mobilewebsite);
    mobilewebsiteDAO.flush();

    return mobilewebsite;
}

The stack trace points to the highlighted line above: mobilecolorswatchmapuserdefinedDAO.store(related_swatchmap);.

The stacktrace is:

2012-12-11 15:14:11.192 59464 [http-8080-2] ERROR  - Unexpected error occurred
org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at [ [Component id = form1]] on component [ [Component id = form1]] threw an exception
    at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:270)
    at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
    at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:248)
    at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234)
    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:781)
    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
    at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:255)
    at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:212)
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:283)
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:185)
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:260)
    ... 22 more
**Caused by: 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:859)
    at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:843)
    at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:847)
    at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:682)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
    at $Proxy44.merge(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    at $Proxy44.merge(Unknown Source)
    at org.skyway.spring.util.dao.AbstractJpaDao.merge(AbstractJpaDao.java:61)
    at org.skyway.spring.util.dao.AbstractJpaDao.store(AbstractJpaDao.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    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 $Proxy76.store(Unknown Source)
    **at com.telventdtn.aghostmobile.service.MobilewebsiteServiceImpl.saveMobilewebsiteMobilecolorswatchmapuserdefined(MobilewebsiteServiceImpl.java:342)**
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    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 $Proxy77.saveMobilewebsiteMobilecolorswatchmapuserdefined(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:416)
    at org.apache.wicket.proxy.$Proxy4.saveMobilewebsiteMobilecolorswatchmapuserdefined(Unknown Source)
    at com.telventdtn.aghostmobile.ArrangeColorsThemePage$SubmitButtonHandler.onSubmit(ArrangeColorsThemePage.java:126)
    at com.telventdtn.aghostmobile.markup.html.form.ObservableButton.notifyObservers(ObservableButton.java:20)
    at com.telventdtn.aghostmobile.markup.html.form.ButtonFactory$1.onSubmit(ButtonFactory.java:34)
    at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1151)
    at org.apache.wicket.markup.html.form.Form.process(Form.java:834)
    at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:762)
    at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:692)
    ... 27 more

回答1:


I have had similar experience wherein the table defined a nullable column, but the domain class marked it as not nullable. An attempt was made to save the object with nulls, and indeed it was persisted, but then failed with that error. Hope this helps.



来源:https://stackoverflow.com/questions/13829157/what-does-null-entities-are-not-supported-by-org-hibernate-event-def-eventcache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!