JPA cascade persist and references to detached entities throws PersistentObjectException. Why?

You can use merge() instead of persist() in this case:

foo = entityManager.merge(foo); 

When applied to the new instance, merge() makes it persistent (actually – returns the persistent instance with the same state), and merges cascaded references, as you try to do manually.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)