Hi Hugi,

Maybe something like isIdenticalToSnapshot() in this Gist will help you?

https://gist.github.com/mrg/4dce22b67175c27f4047

If I recall, this version is for Cayenne 3.0, so there might be a few
tweaks needed for 3.1.

mrg


On Fri, Aug 7, 2015 at 10:16 AM, Hugi Thordarson <h...@karlmenn.is> wrote:

> Hi all.
>
> I’m attempting to implement an audit log using Cayenne, automatically
> storing information on modifications alongside every insert, update and
> delete.
>
> I’m currently doing this by adding a listener on the DataDomain that
> watches for the lifecycle events PrePersist, PreUpdate and PreRemove, and
> there I log what’s happening with the objects. Works perfectly.
>
> One thing I’m wondering though. How can I find what has changed in an
> object in PreUpdate (i.d. when logging modifications)? For those familiar
> with EOF, I do it there by looking at the
> EOEditingContext’s.commitedSnapshotForObject() and comparing the values
> found there with the object’s current values—but I can’t find how to to do
> something similar in Cayenne.
>
> Am I maybe going about this in a completely wrong way (and there’s perhaps
> a much better, more Cayenne-ish way to do this)? If so, I’d be grateful if
> someone could point me in the correct direction :).
>
> Thanks once again,
> - hugi
>
> // Hugi Thordarson
> // http://www.loftfar.is/ <http://www.loftfar.is/>
> // s. 895-6688

Reply via email to