persistence@glassfish.java.net

RE: Not cascading remove

From: Dru Devore <ddevore_at_duckhouse.us>
Date: Tue, 25 Mar 2008 07:20:13 -0700
Gordon, I will try that also. The code was generated by NB and I have not worried about it tell now because I have not had to do any removes like this. This has come up only in my unit testing.



---
Dru Devore


-------- Original Message --------
Subject: RE: Not cascading remove
From: "Gordon Yorke" <gordon.yorke@oracle.com>
Date: Tue, March 25, 2008 10:02 am
To: "persistence@glassfish.dev.java.net"
<persistence@glassfish.dev.java.net>

If you are merging an Order with no other properties set then the relationships will all be removed before you call remove().  This will mean the persistence provider will have no OrderItems to cascade the remove to. You will need to find() the object in the current EM first before calling em.remove() and you should not be calling em.merge();
--Gordon
-----Original Message-----
From: Dru Devore [mailto:ddevore@duckhouse.us]
Sent: Tuesday, March 25, 2008 9:39 AM
To: persistence@glassfish.dev.java.net
Subject: RE: Not cascading remove

I know that the order has items because after completing the operation I can see the items in the database. This may be the problem...for testing purposes I simply wrapped the session bean with a service and am calling it through NB with just the id populated in the object and no query on the object before the delete. I am going to attempt to do the delete with querying the oject using the id first then delete.



---
Dru Devore


-------- Original Message --------
Subject: RE: Not cascading remove
From: James Sutherland <jamesssss@yahoo.com>
Date: Tue, March 25, 2008 9:28 am
To: persistence@glassfish.dev.java.net


Yes, remove(order) should cascade the cascade delete relationship and also
remove the order's items (not just the join table).

Is an error occurring, or are the OrderItems just not deleted? Try setting
the log level to finest to see what is occurring.

Also does the order that you are merging have any OrderItems? Or were they
all removed, or not serialized, if it is empty, then they will not be
removed.

A workaround (to whatever is occurring) may be to edit the mapping using a
DescriptorCustomizer and set the order's orderItems mapping
(ManyToManyMapping) to be privateOwned.



ddevore wrote:
>
> actually I am calling em.remove(em.merge(order)) now I was under the
> impression that the cascade=CascadeType.ALL indicated that a remove would
> remove all the through the relationship not just the intermediary table.
>
> ---
> Dru Devore
>


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Not-cascading-remove-tp16255109p16274773.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.