users@glassfish.java.net

Re: JPA missing hibernate's "delete-orhpan" cascading type

From: <glassfish_at_javadesktop.org>
Date: Tue, 17 Apr 2007 05:57:34 PDT

Spec is ok, Marina. However, when working with EJBs, Your EJB methods can get a reference to EntityManager. Therefore in Your EJB methods You can call EntityManager.delete() whenever You want remove some instances from collection of related entities.

Situation is different in SE environment. Your detached POJO has no way to get EntityManager. If You have a detached entity and Your business method removes from collection of related entities an object, You can not call EntityManager.delete().

Then, conclusion is: modifications You are allowed to do on detached entities are limited to a few specific cases. With pure JPA You can not modify detached entity and let EM synchronize database. To synchronize deletions, You need a non-portable extension, like hibernate's "delete orphan" or toplink's "private ownership".

bye, martin
[Message sent by forum member 'mstanik' (mstanik)]

http://forums.java.net/jive/thread.jspa?messageID=212717