Re: Optimistic locking on delete: appendOptimisticLockingAttributes calls getRetainedSnapshot() but may be null for simple deleteObject()

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Feb 21 2005 - 21:27:59 EST

  • Next message: Andrus Adamchik: "Re: Expression chains"

    On Feb 16, 2005, at 10:08 PM, Mike Kienenberger wrote:

    > java.lang.NullPointerException
    > at
    > org.objectstyle.cayenne.access.ContextCommit.appendOptimisticLockingAtt
    > ributes(ContextCommit.java:599)
    >
    > This appears to be because appendOptimisticLockingAttributes() sets up
    > the
    > qualifier snapshot from the retained ObjectStore snapshot.
    > I suppose an updated object is always guaranteed to have a retained
    > snapshot, but if all that's going on is a delete, there's no retained
    > snapshot since it's been cleared by the previous commit.
    >
    > It looks like the solution is to use getCachedSnapshot() instead (which
    > first returns getRetainedSnapshot() if available).
    > Does this make sense?

    On the one hand it does. On the other hand what if there is no cached
    snapshot either (e.g. some snapshots are invalidated manually or
    removed when a shared cache reaches its size limit)? One solution I see
    is to retain snapshots of deleted objects (just like we do for the
    modified ones) if optimistic locking is involved.

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon Feb 21 2005 - 21:28:05 EST