PersistentObjectException: detached entity passed to persist thrown by JPA and Hibernate
- Jewel Chowdhury
- Bugs
- Nov 03, 2021
This is a typical bidirectional consistency problem. The solution is very simple,
Solution:
Just use the CascadeType.MERGE
instead of CascadeType.PERSIST
or CascadeType.ALL
.
I have had the same problem and CascadeType.MERGE
has worked for me.
Hope it helps….