cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lon Varscsak <lon.varsc...@gmail.com>
Subject Re: Checking what attributes have changed in a DataObject
Date Tue, 14 Feb 2017 16:13:56 GMT
I implemented this in my base data object class:

    public boolean hasKeyChangedFromCommittedSnapshot(String key) {

        ObjectStore objectStore =
((DataContext)getObjectContext()).getObjectStore(); // Need the object
store to access the snapshot data.

        DataRow dataRow = objectStore.getSnapshot(getObjectId()); // Get
the snapshot data.

        EntityResolver resolver = getObjectContext().getEntityResolver();

        ObjEntity entity = resolver.getObjEntity(getObjectId
().getEntityName());

        ObjAttribute attribute = entity.getAttribute(key);

        String dbAttributeName  = attribute.getDbAttributeName();

        String objAttributeName = attribute.getName();

        Object dataRowValue = (dataRow != null) ? dataRow.get(
dbAttributeName) : null;

        Object currentValue = readPropertyDirectly(objAttributeName);



        return (!Util.nullSafeEquals(dataRowValue, currentValue));

    }


On Tue, Feb 14, 2017 at 9:04 AM, Hugi Thordarson <hugi@karlmenn.is> wrote:

> Hi all,
> is there some easy way for me in Cayenne to get information (for example a
> Map) about changes that have been made to a DataObject since it was fetched?
>
> Cheers,
> - hugi

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message