On Apr 25, 2005, at 10:06 PM, Eric Schneider wrote:
> Hi,
>
> Is there public API anywhere that will compare a CayenneDataObject's
> committed and current snapshot? I know something similar happens
> internally before a commit. Is there some commons api that diffs
> Maps?
>
> Thanks!
> e.
Yep. DataRow has "diff" methods:
DataObject object = ...;
DataContext context = object.getDataContext();
DataRow committed =
context.getObjectStore().getSnapshot(object.getObjectId(), context);
DataRow current = context.currentSnapshot(object);
DataRow diff = current.createDiff(committed);
// "createDiff" assumes that no keys are missing from snapshot.
// To be 100% confident we can create the reverse diff... Probably an
overkill.
// DataRow reverseDiff = committed.createDiff(current)
Internally this method is not used as widely as it should due to a
number of special cases accumulated over time. I hope this will change
in the future...
Andrus
This archive was generated by hypermail 2.0.0 : Mon Apr 25 2005 - 22:21:25 EDT