A quick design question whether I'm asking for trouble....

I have a class with self-referential sets. Call it:

 class Person {
    // @hibernate.identifier
    private Long id;

    // @hibernate.set table="parents"
    //  key=child_id value=parent_id cascade="all"
    private Set parents;

    // @hibernate.set table="parents"
    //  key=parent_id value=child_id cascade="all"
    private Set children;

    // @hiberate.set table="siblings"
    //  key=id value="sibling_id" cascade="all"
 }

I don't have problems when I do an initial population of the database via db-utils, but I'm wondering if it's maintainable since editing one object necessarily modifies other objects. Will this confuse hibernate? (I want to say "no," but for me that's still an assumption.) I know everything is fine once I reload everything from the database, but I'm not sure about the impact on a live system.

Example: I add Alice as a parent of Bob. If I now load Alice from disk, she'll have Bob as a child. But if Alice is already in memory how long until she lists Bob as a child? Should I call 'evict()' on Alice when Bob adds her as a parent, and if so what does that do to other references to her?


On a related note, the sets contain the ID of the associated objects. This isn't a problem at the persistence layer, but the external representation needs the sets to contain Persons, not Longs. Is there a conventional way of handling this, or is it just something that needs to be manually done when converting the object from internal to external representation?


Bear



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to