Just two days after I
the errors deleted entity passed to persist, detached entity
passed to persist and id to load is required for loading, some
people came here from web searches.
As I'm not sure if those explanations were clear enough, I'll try to
Deleted entity passed to persist. One entity, supposed to be
deleted, is still referenced / accessed. In my case, I had a problem
with " cascading". The behavior I expected was " on delete
cascade" and " on update cascade". I have those constraints
well in the database, but they weren't right in the Hibernate
annotations. After I changed that, the error stopped. While I was
searching why I was getting this error, I've seen people whose
problem was different. They had, let's say, a list of entities.
Those entities were related to others, and, when deleting, they had
to take care of deleting both the link and the persisted entity.
This was the most common scenario of this problem, and is better
Detached entity passed to persist. One entity, which is supposed
to be up to date but is not, is passed to persist. In my case, I was
trying to create an entity (an Operation), related to another (the
Account where that Operation was taking place). The persist action
was failing because my version of the Account was incorrect. The
solution was just to update the entity.
Id to load is required for loading. Trying to access an entity
without giving an actual identifier. In my case this was the easiest
problem: I was calling find passing a non initialized long.
Passing the correct, initialized values fixed the problem.
Proudly powered by
Pelican, which takes great advantage of Python.
The theme is by
Smashing Magazine, thanks!