Re: How to add a third field to a join table?

From: Mike Kienenberger (mkienen..mail.com)
Date: Thu Sep 22 2005 - 16:30:46 EDT

  • Next message: Gentry, Michael \(Contractor\): "RE: How to add a third field to a join table?"

    You'd now have Role, User, and UserRole DataObjects.

    The User would contain a list of UserRole objects. (to-many)
    The Role would contain a list of UserRole objects. (to-many)
    The UserRole would contain a single Role (to-one), a single User
    (to-one), and your new attribute.

    Yes, you'd create them as you mentioned below.

    On 9/22/05, Joseph Hannon <jah.volcan..mail.com> wrote:
    > Cool. Will you tell me more about the relationship of User and Role,
    > meaning, should they now be to many, to one? Given a User and a few Role
    > objects, how exactly would I persist that combination? Persist through
    > User, Role, create a new UserToRole for each User/Role I will store and
    > persist it?
    >
    > Thanks,
    > Joseph
    >
    >
    > On 9/22/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
    > > Actually now that the join table has meaningful attributes you should
    > > create an ObjEntity for it. Flattened relationships that you setup is
    > > a shortcut to hide meaningless tables. In your case it is no longer
    > > appropriate.
    > >
    > > Andrus
    > >
    > >
    > > On Sep 22, 2005, at 7:04 AM, Joseph Hannon wrote:
    > > > I successfully implemented the seven step instruction piece that
    > > > Todd O'Bryan detailed in the post 'Many to Many Relation'. That
    > > > would be a great addition to the Cayenne docs!
    > > >
    > > > Now, I need to add a new field to the link table 'UserToRole'. This
    > > > new field, 'YYZ', will represent the importance of a specific Role
    > > > for a User as an integer. YYZ clearly cannot be in the Role table
    > > > since Roles are reused and each may have a different importance.
    > > > Based on Todd's instructions, I don't have an objEntity called
    > > > UserToRole, and now I suspect I will need one due to this new
    > > > field. Currently, I can retrieve a List of Role objects from
    > > > within User, but how would I get to this new field YYZ?
    > > >
    > > > Please advise.
    > > >
    > > > Thanks,
    > > > Joseph
    > >
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Thu Sep 22 2005 - 16:30:48 EDT