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

c) just delete the container, it will delete the dependent objects.
Code from the castor doclet dependentorder example :

            db = jdo.getDatabase();
            db.begin();

            Master master = new Master();
            Depend1 depend1 = new Depend1();
            master.setDepend1(depend1);
            Depend2 depend2 = new Depend2();
            master.addDepend2(depend2);

            db.create(master);
            db.commit();

            db.begin();
            master = (Master)db.load(Master.class, new
Integer(master.getOID()));
            db.remove(master);
            db.commit();


-- 
Mickael Guessant

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

Reply via email to