persistence@glassfish.java.net

Re: Not cascading remove

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 24 Mar 2008 14:22:04 -0700

Dru,

Are you calling em.remove(order) or (replace my names with the actual ones)
order.getItems().remove(item)?

If the latter, it only removes the relationships, not the entities.

Regards,
-marina

Dru Devore wrote:
> I am using ejb 3.0 with an order table and order item table. Wanting to
> see how it works allowing it to create the linking table, and actually
> liking I decided to let it be and worry about more important thing. What
> I have is this
>
> order (the main table)
> order_order_item (the linking table)
> order_item (the item table)
>
> When I do a remove it takes it out ofthe linking table but not out of
> the order_item table.
>
> This is how it looks in the order entity
>
> @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
> private List<OrderItem> orderItemList;
>
> It will add them and query them but it does not want to remove them.
> What am I doing wrong?
>
> ---
> Dru Devore