Re: Question about flatten relationship

From: Craig Miskell (cmiskel..lbatross.co.nz)
Date: Sun Nov 24 2002 - 21:13:02 EST

  • Next message: Holger Hoffstätte: "Recent mass update"

    Ahh, I see the problem, and it's at least partially my unclear
    instructions. When i say that the only attributes of the link table
    should be the foreign keys, I mean that literally, the only attributes
    should be that. In your example, the only attributes in StudentCourse
    should be CID and SID. Both must be marked as the PK (a compound
    primary key), and SCID should not exist.

    I hope this makes things a little clearer for you.

    I shall look at updating the documentation (hmmmm ok, I'll look at
    *starting* the documentation :-)) on this in the near future, as I'm
    sure it'll cause others grief as well.

    Craig
    On Mon, 2002-11-25 at 15:04, xuzhou wrote:
    > Hi Craig,
    >
    > Thanks for your reply.
    >
    > I built the relationship as you described. Please examine my attachement.
    >
    > Regards,
    > Xuzhou
    >
    > ----- Original Message -----
    > From: "Craig Miskell" <cmiskel..lbatross.co.nz>
    > To: "xuzhou" <xuzho..oftHome.net>
    > Cc: <cayenne-deve..bjectstyle.org>
    > Sent: Saturday, November 23, 2002 10:23 AM
    > Subject: Re: Question about flatten relationship
    >
    >
    > > Hi,
    > > In the case that the relationship is across a many-to-many link
    > > table that consists solely of the foreign keys of the relationships, then
    > > Cayenne will indeed take care of things, and the relationship is
    > > writable. Cayenne only sets the relationship to readonly if it's
    > > flattened and *not* as described above.
    > >
    > > In your example, I'm assuming that Student has a pk (say, student_id),
    > > Course has a pk (say, course_id), and that there is a link table
    > > StudentCourseLink which has student_id and course_id in it (and only those
    > > attributes).
    > >
    > > In this case, addToCourses should "just work". If it's not, then there's
    > > a bug that needs to be worked out. If it looks like a bug, send me your
    > > Data map xml files and I'll see if there's anything in those that is out
    > > of place. For example, any additional attributes in StudentCourseLink
    > > will be enough for Cayenne to make the relationship "read-only".
    > >
    > > Craig
    > >
    > >
    > > On Fri, 22 Nov 2002, xuzhou wrote:
    > >
    > > > Hi all,
    > > >
    > > > The following italic text is excerpted from Release Notes of Cayenne 1.0b1. I think this feature is very useful, but I hava a question about it. Why the flattened relationship is readonly?
    > > >
    > > > Suppose the many-to-many relationship between student and course. The DataObject, Student, would have method addToCourses(Course obj). But this mothod can not be called to avoid CayenneRuntimeException is thrown. I think if this method can be called, i.e.,the flatten relationship is writable, the DataObject could be operated more convenient.
    > > >
    > > >
    > > > 8. Added support for flattened relationships. Modeller now suggests all available
    > > > paths from the source entity to the destination entity for selection. For simple flattened
    > > > relationships that span a many-many link table consisting solely of fk's to the linked rows,
    > > > cayenne will automatically add/remove the link records. In that case, there is no need to
    > > > have an ObjEntity for the link record, and this is in fact discouraged. All other flattened
    > > > relationships are set "readOnly" and cannot be modified.
    > > >
    > > >
    > > > Regards,
    > > >



    This archive was generated by hypermail 2.0.0 : Sun Nov 24 2002 - 21:12:09 EST