Auto-update between contexts

From: Dave (sanxion200..ahoo.com)
Date: Thu Dec 30 2004 - 03:22:01 EST

  • Next message: Dave: "Re: Auto-update between contexts"

    I use the code below to copy objects from a main context to a temporary.
    I then update a field of the copy and commit changes. However the field of
    the original object isn't updated. Have I misunderstood something? I read
    in prior mails that objects are auto-synchronized between contexts when
    comitted.

    Thanks, Dave

    // check the name of the player
    System.out.println("Name "+ proto.getName());

    // --> This gives Ron

    // copy player object to temporary context
    DataContext context= DataContext.createDataContext();
    ArrayList list = new ArrayList();
    list.add(player);
    List localObjects = context.localObjects(list);
    Player playerCopy = (Player) localObjects.get(0);

    // update name and save changes
    protoCopy.setName("Dave");
    context.commitChanges();

    // check the name of the player
    System.out.println("Name "+ proto.getName());

    // --> This gives Ron

                    
    __________________________________
    Do you Yahoo!?
    The all-new My Yahoo! - What will yours do?
    http://my.yahoo.com



    This archive was generated by hypermail 2.0.0 : Thu Dec 30 2004 - 03:22:03 EST