This one time, at band camp, "H�hne, Thomas" said:

HT>I'm using Castor as persistence layer for JAVA Objects. What I try to do is
HT>to delete an object Container, from which other objects (Elements) depend.
HT>Class "Container" aggregates Objects of class "Element" (zero..many). In the
HT>database (Oracle), Table ELEMENT has a foreign key constraint to Table
HT>CONTAINER. The mapping for Element has the attribute "depends=Container" in
HT>the class-tag. Each object has an attribute id, which identifies it. Element
HT>and Container extend a class which implements TimeStampable.
HT>What do I have to do when deleting an instance of Container?
HT>a) recursively delete all dependent Elements, from leafs to nodes (Elements
HT>can build a tree by referencing eachother as parent Element), and then
HT>remove Container (I'd like to avoid it)
HT>b) set all references of Container to the contained Elements to null, and
HT>then remove Container (doesn't work)
HT>c) ....?

Thomas,

Based on your description, it sounds like you're using Castor's
object dependency feature correctly. Castor will automatically delete
dependent objects when deleting the master object. See the JDO examples
in src/examples/jdo and src/examples/myapp. There is an example of object
dependency where Product is the master and ProductDetail is the slave.
Lines #120-128 of src/examples/jdo/Test.java demonstrate the deletion
of a master object and it's slave object(s). Notice that only the master
object is explicitly deleted.

Taken from
http://www.castor.org/castor-one.html#Dependent-and-related-relationships: 

    "If an object class declared as depends on another class, it may
    not be created, removed or updated separately."

Bruce
-- 
perl -e 'print unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to