Versioning and persistence

Patrick Logan
Wed, 21 May 97 17:26 PDT

>>>>> "Chris" == x22068  <Chris> writes:

    Chris> What does Gemstone do when obj A points to obj B and obj B
    Chris> gets updated to a new version. Does obj A point to the
    Chris> original version or the latest version? Whichever way
    Chris> Gemstone does it, what if that wasn't what you wanted?

Let's say B is an instance of ClassB-1 and a new version of the class,
ClassB-2 is defined. B is still an instance of ClassB-1 until somebody
tells it to migrate. Migration can be triggered in various ways. The
easiest is to tell the class to #migrateAllInstances.

If A references B then it still references B after the
migration. Think of this as similar to sending #become: to B in
Smalltalk-80. If it wasn't what you wanted then you need to use a
migration strategy that avoids migrating B.

This gets crufty in the corners of Gemstone because the overall
assumption is that eventually all instances of a class will be
migrated to the latest version. If this is not the case, then it is
better to handle the problem by defining a new class that is *not* a
version of an old class. Then instead of migrating some instances and
keeping others, the solution is to create new instances from the ones
you would have "migrated" and avoid creating new instances for the
ones you want to keep around.

Something like:

    aCollectionOfOldInstances collect:
       [ :each | 
        (NewClass shouldReplace: each)
                [NewClass replace: each]

This answers a collection of instances, some of which are replacements
and some of which are the old ones to keep around. But in this case,
NewClass is *not* a version of OldClass. And the "replaced" instances
have *not* been migrated. They still exist and will only go away if
references are explicitly removed. Above, aCollectionOfOldInstances
still refers to the old instances, so...

    aCollectionOfOldInstances := nil

will get rid of those references.

Patrick Logan       
Voice 503-533-3365            Fax   503-629-8556
Gemstone Systems, Inc