To reproduce:
- Put an entity into the persistence context, then remove it. Now you have a detached entity.
- Call EntityManager#persist(Object) with the detached entity.
- Observe that Hibernate throws a PersistenceException. Note that the javadocs do not permit this kind of exception to be thrown.
Perhaps an IllegalArgumentException should be thrown instead? |