Re: Many to Many Relation

From: Dhruti Ramani (dhrutiraman..ahoo.com)
Date: Thu Jun 30 2005 - 10:08:37 EDT

  • Next message: Kevin Menard: "Re: Sorting Relationships"

    I am so confused now. if you have same set up then how
    come it does not generate add/remove methods for me
    for M to M relation?

    I am attaching *map.xml and cayenne.xml, if some one
    can look at that figure out what I am doing wrong,
    that would be really gr8 help. Objects I am interested
    are SystemUser and UserRole and the join table is
    UserRole_SystemUser.

    Thanks,
    Denna
    --- Mike Kienenberger <mkienen..laska.net> wrote:

    > 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
    >

                    
    ____________________________________________________
    Yahoo! Sports
    Rekindle the Rivalries. Sign up for Fantasy Football
    http://football.fantasysports.yahoo.com



    This archive was generated by hypermail 2.0.0 : Thu Jun 30 2005 - 10:08:39 EDT