users@glassfish.java.net

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

From: Jacek Laskowski <jacek_at_laskowski.net.pl>
Date: Mon, 16 Apr 2007 10:03:44 +0200

On 4/16/07, glassfish_at_javadesktop.org <glassfish_at_javadesktop.org> wrote:
> I am perplexed how i am expected to modify a detached entity if my modification can result in some deletions of related entities in pure JPA style.
>
> Before JPA spec, all major persistence frameworks (hibernate, toplink, kodo) recognized such a need and provided a support for this. Not so JPA. I was told by Christian from Hibernate team (thanks), this feature does not fit in JPA entity lifecycle model.
>
> I believe this feature is really crucial, without it i can not modify a detached entity in case modification may result in some related entitty deletion (please correct me if i am wrong).
> Idea of rich domain model is negated - businness methods which could delete any entity (fairly obvious case) need reference of EntityManager. It seems to me JPA is not suitable for non-managed environment despite spec calculates with such use.
>
> What programming model is expected for JPA outside of application server?
> Is a real chance to use it without non-portable extensions?

Hi,

Unless I've misunderstood the delete-orphan cascade type, where it is
to delete (child) entities that have been dereferenced from their
parent entity, it's possible to mimic the behavior and remove the
child entity when it's dereferenced. I can't imagine a situation where
the delete-orphan would apply, but it's most likely that I have never
used it or even more importanly have never played with Hibernate as
much as I should've been.

Could you describe a scenario where delete-orphan applies and JPA can't handle?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl