Re: Setting a many to many relationship List

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jun 16 2005 - 17:43:42 EDT

  • Next message: Andrus Adamchik: "Re: Persisting a HashTable"

    Albert,

    Current templates do not generate this method. It is very easy to
    change the template to add it ... or define it manually in a
    DataObject subclass. I guess we may provide it in a default template
    at some point too - this is really no big deal.

    Note that unlike EOF, Cayenne uses functionality similar to
    "addObjecToBothSidesOfRelationship" behind the scenes automatically.
    So every set or add method connects two objects on both sides. So
    whatever your custom implementation might be, the best bet is to
    iterate through the list and call "addToManyTarget" defined in a
    superclass on each object.

    Andrus

    On Jun 16, 2005, at 5:27 PM, Albert Jagnow wrote:
    > When working with a many to many relationship in cayenne using a
    > flattened relationship is it possible to just set the List of
    > related objects instead of adding each one at a time. I didn’t see
    > a set method generated only a get method. Without getting too
    > specific the application I am working with has an item and a list
    > of users who each item affects. When I create the item object if I
    > already know the list of users can’t I just call
    > item.setAffectedUsers(userList). I guess I can write code to
    > iterate over the List, but I am a long time EOF user, and since
    > cayenne seems to work a lot like EOF I was sort of expecting a set
    > method that would accomplish this in a single line of code. Is
    > there something that I am missing?
    >
    >
    >
    > --Albert
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Thu Jun 16 2005 - 17:43:46 EDT