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

From: Joseph Hannon (jah.volcan..mail.com)
Date: Thu Sep 22 2005 - 20:10:36 EDT

  • Next message: Mike Kienenberger: "Reconnecting serialized DataObjects"

    Thanks! Got it working.

    Joseph

    On 9/22/05, Gentry, Michael (Contractor) <michael_gentr..anniemae.com>
    wrote:
    >
    > User <-->> UserToRole <<--> Role
    > I'd also add helper methods to your User (and perhaps Role) subclass.
    > Things like addRole(Role role). This helper method would create a new
    > UserToRole and set the user/role relationships in the new UserToRole object.
    > This will keep the code which uses the User a bit cleaner.
    > You would persist everything with a normal dataContext.commitChanges()
    > when you are done.
    > /dev/mrg
    > -----Original Message-----
    > *From:* Joseph Hannon [mailto:jah.volcan..mail.com]
    > *Sent:* Thursday, September 22, 2005 4:14 PM
    > *To:* cayenne-use..bjectstyle.org
    > *Subject:* Re: How to add a third field to a join table?
    >
    > 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 - 20:10:37 EDT