MODIFIED set prematurely

From: Cris Daniluk (cris.danilu..mail.com)
Date: Wed Jan 25 2006 - 09:52:52 EST

  • Next message: Andrus Adamchik: "Re: MODIFIED set prematurely"

    In CayenneDataObject, I believe the persistenceState is being
    prematurely set to MODIFIED:

        public void writeProperty(String propName, Object val) {
            resolveFault();

            // 1. retain object snapshot to allow clean changes tracking
            // 2. change object state
            if (persistenceState == PersistenceState.COMMITTED) {
                persistenceState = PersistenceState.MODIFIED;
                dataContext.getObjectStore().retainSnapshot(this);
            }
            // else....
            // other persistence states can't be changed to MODIFIED

            writePropertyDirectly(propName, val);
        }

    If the value mapped to propName is already val, this will trigger a
    MODIFIED. It won't trigger a write, because of the optimistic updates,
    but it will still blow up if the object is readonly.

    I think the read-only error should only happen if the snapshots are
    different, or the state should not be set to MODIFIED until a
    difference is verified. This isn't as much of a problem in
    writeProperty (which makes a better example) as it is in
    addToManyTarget. Right now, unless I delete the reverse relationship
    from a readonly object in the modeler, when I add a relation to the
    writable object, it triggers the reverse relationship and sets the
    state to MODIFIED, even though no database write is required. That
    seems to limit the value of readonly...

    Cris



    This archive was generated by hypermail 2.0.0 : Wed Jan 25 2006 - 09:52:55 EST