On 19 Dec (09:20), Jim Downing wrote:

> Thanks - I'd used the advance in Tom's manual to do the mapping, but I
> was trying to maintain the relationship in my persistent objects
> (rather than making the client do it, as in the FAQ), which was
> probably the cause of my problems.

Thats exactly what I'm doing:

class Child {

    public setParent(Parent newParent) {

        // Remove myself from old Parent
        if (this.parent != null) {
            this.parent.getChildren().remove(this);
        }

        // Add to new Parent
        newParent.getChildren().add(this);

        // Set new Parent
        this.parent = newParent;
    }
}

This is similar to the Composite Pattern (or better, a part of it):

http://www.idg.net/english/crd_composite_948016.html

-- 
Christian Bauer
[EMAIL PROTECTED]


-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now!  Before the Holidays pass you by.
T H I N K G E E K . C O M      http://www.thinkgeek.com/sf/
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to