org.hibernate.event.def.EventCache 不支持 null 实体是什么意思?

2023-12-23

我在尝试保存实体时收到错误。我仅在启动服务器时收到此错误,而不是在使用 dbunit 运行单元测试时收到此错误。

我正在努力拯救一个协会。我的单元测试应该与我在手动测试时遇到的情况完全相同。我正在关系的一端添加一个新实体,其中之前不存在任何关系。

我正在使用 HSQLDB 进行单元测试,而 Web 应用程序正在使用 SQL Server。

我所做的搜索并未取得成果。对这条消息的解释将非常有用。

这是测试用例(效果很好!):

    @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());
    }

这是服务(注意:我目前正在执行删除/保存操作,前提是已经存在关联 - 这应该是一对一的,但是是遗留的):

@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;
}

堆栈跟踪指向上面突出显示的行:mobilecolorswatchmapuserdefinedDAO.store(related_swatchmap);.

堆栈跟踪是:

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

我有过类似的经历,其中该表定义了一个nullable列,但域类将其标记为not nullable。尝试使用以下方式保存对象nulls,确实它被保留了,但随后因该错误而失败。希望这可以帮助。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

org.hibernate.event.def.EventCache 不支持 null 实体是什么意思? 的相关文章

随机推荐

  • iPhone 上的 HTML5 视频元素有边框

    我最近一直在构建一个应用程序 并在开始时播放加载动画 只是一个 mp4 视频 出于美观目的 除了 iPhone 之外 它在任何地方都可以正常工作 问题在于 视频的某些部分周围有一条灰线 每边并不相同 如果我尝试对页面进行屏幕截图 则线条将不
  • Pandas.groupby.apply() 中的内存泄漏?

    我目前正在使用 Pandas 进行一个 csv 源文件大约 600mb 的项目 在分析过程中 我将 csv 读入数据帧 对某些列进行分组并对分组的数据帧应用一个简单的函数 我注意到在此过程中我进入了交换内存 因此进行了基本测试 我首先在 s
  • Android 应用程序可以在模拟器中运行,但不能在设备中运行

    我使用 android 1 6 api 4 创建了一个 android 应用程序 android minSdkVersion 是 3 我使用的模拟器运行这个应用程序是2 2 它在模拟器中工作正常 然后我将其安装到 htc Hero andr
  • 为什么 Blazor 应用程序中的 XML 验证在本地主机上和作为 Azure 静态 Web 应用程序给出不同的消息?

    edit我做了一个简化的回购协议https github com GilShalit XMLValidation https github com GilShalit XMLValidation 我正在 Blazor WebAssembly
  • 如何将 hset 与 django-redis-cache 一起使用?

    我是 django redis 的新手 我开始熟悉 heroku redis 插件 但是 我只能使用set and get 当我尝试使用其他方法时 例如hset 我收到此错误 RedisCache object has no attribu
  • Android Studio 很慢

    我有一个项目 里面有大约 20 个模块 Gradle clean 大约需要 5 分钟 同样 如果我添加一个新模块 gradle 更新项目需要超过 5 分钟 不依赖于外部库 依赖关系仅存在于项目内部的几个模块之间 我有相同的项目 没有 gra
  • 如何获取工作流活动 (SharePoint) 中的上下文项

    我正在为 sharepoint 工作流编写自定义活动 但我不知道如何使用当前工作流项目 SPWeb 或 SPSite I see http blogs microsoft co il blogs davidbi archive 2008 0
  • htaccess如何将子目录重定向到外部URL

    I tried 301 Redirect Old File Redirect 301 www mydomain com subdirectory http newurl com 但这让我进入了 newurl com subdirectory
  • Android 2.3 中出现“无对等证书”错误,但 4 中则没有

    得到 javax net ssl SSLPeerUnverifiedException No peer certificate error 在运行 Android 2 3 的模拟器中 但在 4 中则不然 在 4 中 它运行得很好 我正在尝试
  • varchar 的 DbString、IsFixedLength 和 IsAnsi

    我是 Dapper 的新手 想知道为什么当我的代码在没有它的情况下运行时会出现以下建议 Ansi 字符串和 varchar https github com StackExchange Dapper ansi strings and var
  • MBCS 编码未知

    我正在尝试在 Python 中打开带有 MBCS 编码的文件 但出现错误 如果我写 fileIN open filename r encoding mbcs I get Traceback most recent call last Fil
  • 安装.NET Core Runtime和SDK后需要重启吗?

    我们即将在生产环境中部署 netcore 2 0 应用程序 但我们需要首先安装 NET Core 运行时和 SDK 安装是否需要重启才能生效 既然是生产 我们不希望这种情况发生 我们安装了以下内容here https www microso
  • RAII 和系统资源清理

    RAII 是资源清理的一个很好的解决方案 然而 RAII 基于堆栈展开 如果进程异常终止 堆栈将不会被展开 这意味着 RAII 在这种情况下不起作用 对于进程生命周期的资源来说 这没什么好担心的 但是对于文件系统生命周期或者内核生命周期的资
  • 原则上,Android 设备是否可以通过蓝牙/GameKit 与 iPhone 连接?

    我对纯理论不感兴趣 但作为近期或中期的实际可能性 比如 12 24 个月内 作为一名熟悉 但不专门研究 两个主要智能手机平台的开发人员 我是否应该期望 Android 库的出现 它可以将自己欺骗到 iPhone 应用程序基于 GameKit
  • Spring mockMvc 在我的测试中不考虑验证

    我正在尝试使用mockMvc 设置集成测试 但遇到了问题 事实上 spring没有集成任何验证注解 为了更精确 我放置了可以测试的 Controller 类的代码 Controller public class UserRegisterCo
  • 带有外部更新的 NHibernate 二级缓存

    我有一个 99 只读的 Web 应用程序 有一个单独的服务以特定的时间间隔 例如每 10 分钟 更新数据库 该服务如何告诉应用程序使其二级缓存失效 它真的重要吗 我实际上并不关心我是否有太多过时的数据 如果我不使缓存失效 记录需要多长时间才
  • FBSDK 的 LLDB 问题,每当我放置断点时,我都会收到错误,并且无法打印任何变量

    每当我设置断点并尝试访问任何变量时 我都会收到此错误 如果我尝试在控制台中打印变量 则会收到以下错误 lldb p someVar error Error in auto import failed to get module Jogabo
  • 维护多个设置文件

    目前 我有一个包含各种单选按钮 目录浏览器 日期选择器等的表单 应用程序使用这些设置 并执行文件删除任务 我想知道将这些设置保存到可以稍后加载的外部文件的最佳策略是什么 因此基本上每个配置都可以被加载 执行 然后加载另一个配置 此外 配置可
  • Angular 2 Http 重试时间

    我正在尝试使用retryWhen在 HTTP 调用中 当尝试像这样使用时它工作得很好 return this http get environment apiUrl track this user instance id this curr
  • org.hibernate.event.def.EventCache 不支持 null 实体是什么意思?

    我在尝试保存实体时收到错误 我仅在启动服务器时收到此错误 而不是在使用 dbunit 运行单元测试时收到此错误 我正在努力拯救一个协会 我的单元测试应该与我在手动测试时遇到的情况完全相同 我正在关系的一端添加一个新实体 其中之前不存在任何关