users@glassfish.java.net

Re: JPA: Delete children in OneToMany

From: <glassfish_at_javadesktop.org>
Date: Tue, 10 Feb 2009 10:25:03 PST

> This will remove the relation between A and B in the
> jointable (a_b) but the B entity will not be removed
> from the "b" table. Is this correct behaviour? Thus,
> do i need to remove from "b" table manually? I would
> have expected that this should have been cascaded to
> "b" automatically.

No, you have to actually individually remove the B entities from the database, you can't simply remove them from the parent list.

Truth is, this seemingly simple process can actually be a rats nest of complexity, so the JPA literally punted on this issue to get v1 out the door. JPA 2 will have facilities to do what you want.

But for now, you need to maintain this relationship yourself.
[Message sent by forum member 'whartung' (whartung)]

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