Re: Many to Many Relation

From: Mike Kienenberger (mkienen..laska.net)
Date: Wed Jun 29 2005 - 18:17:02 EDT

  • Next message: Kevin Menard: "Sorting Relationships"

    Dhruti Ramani <dhrutiraman..ahoo.com> wrote:
    > I thought so but I read the userguide and misunderstood it. Now i can have
    M to M relations between UserRole and SystemUser. Thank you so much.
    >
    > Another Problem . When I generate those two classes I don't get any add or
    remove methods, I just got getUsers() in UserRole and getRoles() in
    SystemUser.
    >
    > In userguide I read somewhere that "Most of flattened relationships are
    treated as read-only by Cayenne. Only one (the most commonly used) type is
    read/write. It is many-to-many (n:m) flattened relationships with a single
    join table."
    >
    > So how do I insert values to those objects?

    No, a simple many-to-many relationship like that should automatically
    generate the add/remove methods.

    I have an almost identical setup and it generates code like this:

        public void addToRoleList(SecRole obj) {
            addToManyTarget("roleList", obj, true);
        }
        public void removeFromRoleList(SecRole obj) {
            removeToManyTarget("roleList", obj, true);
        }
        public List getRoleList() {
            return (List)readProperty("roleList");
        }

    [From the code of the equivalent class as your SystemUser with SecRole being
    the same as UserRole]

    -Mike



    This archive was generated by hypermail 2.0.0 : Wed Jun 29 2005 - 18:14:09 EDT