Best way to inform (and handle cached object refreshing) of externally-updated database records?

From: Mike Kienenberger (mkienen..laska.net)
Date: Fri Nov 19 2004 - 16:32:03 EST

  • Next message: Bryan Lewis: "mostly shared model"

    Once a day, an external batch job runs and updates some fields in tables my
    application has marked as "read-only"

    Before I ported my app to cayenne, it ran under WebObjects EOF, and I
    handled the situation like this:

    The batch job updated a LAST_EXTERNAL_UPDATE date field in its own table
    after it finished.

    My web app on every login attempt would run a checkLastExternalUpdate()
    method which, if the LAST_EXTERNAL_UPDATE field changed, would then perform
    EditingContext.invalidateAllObjects() and force all objects used by the
    application to be refetched on next reference.

    I'd like to do this "better" under cayenne, only forcing a refetch of
    objects in specific (read-only) tables rather than every object in the app.
    I'm not thrilled with the LAST_EXTERNAL_UPDATE approach either, but it's
    better than listening on a socket.

    However, I'm unclear how to go about this with Cayenne.

    The best I can come up with is one (or both) of the following:

            
    getDataContext().invalidateObjects(getDataContext().getObjectStore().getObjects());

            getDataContext().getObjectStore().getDataRowCache().clear();

    Thanks,

    -Mike



    This archive was generated by hypermail 2.0.0 : Fri Nov 19 2004 - 16:30:31 EST