[flattened relationships] update relationship only will not execute

From: Laszlo Spoor (lspoor_cayenn..otmail.com)
Date: Sat May 10 2003 - 15:48:28 EDT

  • Next message: David W. Taylor: "Newbie: suggestions for help with JBuilder...."

    Hi guys,

    Andrus,
    I have tried your latest build and it works perfectly. Many thanks! However,
    I think I could have noticed another glitch, but let me verify with you, I
    could
    do some things wrong.

    Suppose you have two objects: a Photo and a PhotoType, the relationship
    between
    them is many-to-many. My mapping of the n:n relationship is done like
    described in the manual:
    http://www.objectstyle.org/cayenne/userguide/advmodel/flattenedrel.html

    Now if I retieve a existing photo and a type using the primary key:

      //Photo
      ObjectId oi
        = new ObjectId(Foto.class, "id", new Integer("1").intValue());

      Photo pto = (Photo) mContext.registeredObject(oi);

      //Photo type
      ObjectId oi
        = new ObjectId(Foto.class, "id", new Integer("2").intValue());
      PhotoType pte = (PhotoType) mContext.registeredObject(oi);

    If I only want to create a relationship between the two the only code needed
    to
    do so is:

       pto.addToType(pte);
       mContext.commitChanges(Level.WARN);

    The result is that nothing is being send to my datastore. But, if I do
    something
    like:

       pto.setName("anotherName");
       pto.addToType(pte);
       mContext.commitChanges();

    It works allright. The name is changed and the relationship is created. I
    could
    of course, remove the object from the datastore and recreate is (mySQL has
    no
    problem with that), but that seems a bit odd.

    Can anyone please tell me how I should deal with this one?

    Thanks in advance, Laszlo

    _________________________________________________________________
    MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
    http://join.msn.com/?page=features/virus



    This archive was generated by hypermail 2.0.0 : Sat May 10 2003 - 15:48:10 EDT