Re: Non-physical delete... again

From: Mike Kienenberger (mkienen..mail.com)
Date: Mon Jun 01 2009 - 11:24:12 EDT

  • Next message: Andrus Adamchik: "Re: Non-physical delete... again"

    I have a legacy Cayenne 1.1.4 app that does the same thing.
    I handled it back then by doing something similar. Back then, we
    could set up a delegate to intercept all queries, and I automatically
    added the restricting qualifier to each select query.

    I never deleted from the application level code . Instead, I had a
    special invalidation manager class that I called instead which would
    update the boolean field (and a timestamp) and invalidate all objects
    referencing that object.

    It worked out well enough, although there were issues with the
    invalidation propagating to all sessions exactly when I wanted it to
    happen.

    However, I didn't have any flattened relationships back then -- too
    ignorant to know any better.

    On Mon, Jun 1, 2009 at 11:09 AM, Andrey Razumovsky
    <razumovsky.andre..mail.com> wrote:
    > Hi,
    >
    > We've discussed this time ago, but I'm back now with some ideas.
    >
    > Current situation:
    > I have to use special boolean column named "deleted" in all DB tables. That
    > is, I never (or very rarely) do something like "DELETE FROM ..." or
    > "context.deleteObject()", instead I do "UPDATE... SET deleted=true" or
    > cdo.setDeleted(true). To select only undeleted records, I add qualifier like
    > "deleted=true" to every ObjEntity. Also I add pre-update listeners to all
    > entities which unregisters object and processes delete rules (also
    > respective to 'deleted' field) if 'deleted' flag is set.
    > It is obvious that Cayenne cannot completely handle this situation. One
    > example is CAY-1109, but it can be workarounded as described above. More
    > serious problems are:
    > - I cannot use properly flattened relationships, because 'deleted' qualifier
    > is not applied to DBEntities selection (e.g. in 'medium' table of
    > many-to-many relationship)
    > - flattened expressions, e.g. toArtist.name="Rublev" also miss that
    > qualifier
    > - there is no objects with DELETED state, only with MODIFIED
    > ...and so on.
    >
    > I faced this situation since the first days I used Cayenne. Now when I
    > thought about this a bit, I think I can handle it with two new features. I'm
    > not sure they completely match Cayenne paradigm, but...
    >
    > 1. DBEntity qualifier. This is same as ObjEntity qualifier, but applied
    > every time DBentity is being added to select sql. I will add DBEntity
    > qualifier 'deleted=false' and drop current ObjEntity's
    >
    > 2.  Deletion strategy for DataDomain. This means I do not always fire
    > DeleteAction, but maybe something else (update action in my case).
    >
    > Any comments much appreciated.
    >
    > Thanks,
    > Andrey
    >



    This archive was generated by hypermail 2.0.0 : Mon Jun 01 2009 - 11:25:04 EDT