2010/5/10 Ólafur Gauti Guðmundsson <
oli....@gmail.com>:
> Versioning would be a great feature to support, as it is one required
> by many enterprise systems. However, it quickly becomes a complex
> subject. Ideally, it is something that I would like to have
> implemented in Mongo (something like a versioned collection).
There are 3 things that come up when we talk about some kind of
version(ed/ing). One is support for something like JPA's @Versioned,
where if you have an old instance of the object you will get an error
if you try to save it. Two is keeping a history of all changes (so
that you have many versions of you entity stored), and the third
revolves around around the issues of loading different versions (note,
there is only one stored instance of your entity, but it might have
been stored by an old version of your entity class -- like before you
added a field, or renamed one) of you entities from the datastore. The
third is more about migrating schema changes and loading that data
from newer instances (assuming you don't need to run old versions of
your application at the same time). Some people call this a "live
upgrade" where you deploy a new version of your application (where you
have changed the schema -- class files -- in an incompatible ) but
don't want to reprocess all stored instanced before the deployment.
Live upgrades allow for no downtime, but may require more code to
support intermediate or transitional data loading and schema changes.
The idea of this feature is for the first case (@Versioned JPA-style).
I think we can do this efficiently using updates with a filter on the
current version. This feature is especially important for GWT and
places where you serialize your entities over a matter of seconds or
minutes, or more. It will catch the "someone else edited it first"
problem.
> I assume you need to maintain a version history. This means that you
> can browse all versions of the content, to see what has changed. Allow
> rolling back to a previous state, merging, etc.
>
> You would normally need more than just the version number (person
> making the change, date the change was made, etc.), but that could be
> implemented on the application level.
>
> But you would also need something linking a set of versions together.
> Would there be a parent object for the Version list, or could this be
> implemented by having an @Embedded version list?
>
> Maybe versioning is something that the Mongo people intend to
> implement. Need to check that.
I don't think anyone has asked for versioning support. I have a simple
change-log that I do based on the prePersist lifecycle event in each
of my entities which I want to track. I just inspect each field and
for one that has changed I create a new EntityChanged(who, field, old,
new) object, and then I save them.