Searched for hours for a solution to this problem and found absolutely nothing, so now that I have the solution, I'll post this here, so that others don't have to go through the same pain.
The following stack trace was caused when I added a @OneToOne mapping to a new entity. What was the cause?
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/>
I have the situation where entity A had a @ManyToOne relationship with entity B. Entity B in turn reciprocated the relationship as a @OneToMany.
The problem started when I added entity C with a @OneToOne relationship with entity A. In the end, I removed the @ManyToOne relationship from entity A (to entity B).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With