首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hibernate / Jpa异常无法重新关联未初始化的瞬时集合

Hibernate / Jpa异常无法重新关联未初始化的瞬时集合
EN

Stack Overflow用户
提问于 2020-03-18 05:48:51
回答 1查看 1.1K关注 0票数 2

我花了几个小时寻找这个问题的解决方案,但什么也没有找到,所以现在我有了解决方案,我把这篇文章贴在这里,这样其他人就不必经历同样的痛苦了。

当我将@OneToOne映射添加到新实体时,导致了以下堆栈跟踪。原因是什么?

代码语言:javascript
复制
2020-03-17 22:10:26.091 ERROR 46765 --- [ XNIO-12 task-9] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.HibernateException: could not reassociate uninitialized transient collection]
2020-03-17 22:10:26.092 ERROR 46765 --- [ XNIO-12 task-9] my.app.aop.logging.LoggingAspect      : Exception in ch.hockai.web.rest.MyEntityResource.updateMyEntity() with cause = 'org.hibernate.HibernateException: could not reassociate uninitialized transient collection' and exception = 'could not reassociate uninitialized transient collection; nested exception is org.hibernate.HibernateException: could not reassociate uninitialized transient collection'

org.springframework.orm.jpa.JpaSystemException: could not reassociate uninitialized transient collection; nested exception is org.hibernate.HibernateException: could not reassociate uninitialized transient collection
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:351)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:253)
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:536)
<snip/>
Caused by: org.hibernate.HibernateException: could not reassociate uninitialized transient collection
    at org.hibernate.event.internal.ProxyVisitor.reattachCollection(ProxyVisitor.java:75)
    at org.hibernate.event.internal.WrapVisitor.processCollection(WrapVisitor.java:70)
    at org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:104)
<snip/>
EN

回答 1

Stack Overflow用户

发布于 2020-03-18 05:48:51

我遇到这样的情况:实体A与实体B之间存在@ManyToOne关系。实体B反过来将该关系作为@OneToMany进行交互。

当我添加与实体A具有@OneToOne关系的实体C时,问题就开始了。最后,我从实体A(到实体B)中删除了@ManyToOne关系。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60730718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档