Search in sources :

Example 1 with ObjectChangeSet

use of org.eclipse.persistence.sessions.changesets.ObjectChangeSet in project jmix by jmix-framework.

the class EclipselinkAttributeChangesProvider method getOldValueByImplementation.

@Override
@Nullable
protected Object getOldValueByImplementation(Object entity, String attribute) {
    checkEntityByImplementation(entity);
    PropertyChangeListener propertyChangeListener = ((ChangeTracker) entity)._persistence_getPropertyChangeListener();
    ObjectChangeSet objectChanges = ((AttributeChangeListener) propertyChangeListener).getObjectChangeSet();
    if (objectChanges != null) {
        ChangeRecord changeRecord = objectChanges.getChangesForAttributeNamed(attribute);
        if (changeRecord != null) {
            return changeRecord.getOldValue();
        }
    }
    return null;
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) AttributeChangeListener(org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener) ObjectChangeSet(org.eclipse.persistence.sessions.changesets.ObjectChangeSet) ChangeTracker(org.eclipse.persistence.descriptors.changetracking.ChangeTracker) AggregateChangeRecord(org.eclipse.persistence.sessions.changesets.AggregateChangeRecord) ChangeRecord(org.eclipse.persistence.sessions.changesets.ChangeRecord) Nullable(org.springframework.lang.Nullable)

Example 2 with ObjectChangeSet

use of org.eclipse.persistence.sessions.changesets.ObjectChangeSet in project jmix by jmix-framework.

the class EclipselinkAttributeChangesProvider method buildChangesByImplementation.

@Override
protected void buildChangesByImplementation(AttributeChanges.Builder builder, Object entity, BiFunction<Object, MetaProperty, Object> transformer) {
    checkEntityByImplementation(entity);
    PropertyChangeListener propertyChangeListener = ((ChangeTracker) entity)._persistence_getPropertyChangeListener();
    ObjectChangeSet objectChanges = ((AttributeChangeListener) propertyChangeListener).getObjectChangeSet();
    if (objectChanges != null) {
        buildChanges(builder, objectChanges, metadata.getClass(entity), transformer);
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) AttributeChangeListener(org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener) ObjectChangeSet(org.eclipse.persistence.sessions.changesets.ObjectChangeSet) ChangeTracker(org.eclipse.persistence.descriptors.changetracking.ChangeTracker)

Example 3 with ObjectChangeSet

use of org.eclipse.persistence.sessions.changesets.ObjectChangeSet in project jmix by jmix-framework.

the class EclipselinkAttributeChangesProvider method getChangedAttributeNamesByImplementation.

@Override
protected Set<String> getChangedAttributeNamesByImplementation(Object entity) {
    checkEntityByImplementation(entity);
    PropertyChangeListener propertyChangeListener = ((ChangeTracker) entity)._persistence_getPropertyChangeListener();
    ObjectChangeSet objectChanges = ((AttributeChangeListener) propertyChangeListener).getObjectChangeSet();
    if (objectChanges != null) {
        return new HashSet<>(objectChanges.getChangedAttributeNames());
    }
    return Collections.emptySet();
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) AttributeChangeListener(org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener) ObjectChangeSet(org.eclipse.persistence.sessions.changesets.ObjectChangeSet) ChangeTracker(org.eclipse.persistence.descriptors.changetracking.ChangeTracker) HashSet(java.util.HashSet)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)3 ChangeTracker (org.eclipse.persistence.descriptors.changetracking.ChangeTracker)3 AttributeChangeListener (org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener)3 ObjectChangeSet (org.eclipse.persistence.sessions.changesets.ObjectChangeSet)3 HashSet (java.util.HashSet)1 AggregateChangeRecord (org.eclipse.persistence.sessions.changesets.AggregateChangeRecord)1 ChangeRecord (org.eclipse.persistence.sessions.changesets.ChangeRecord)1 Nullable (org.springframework.lang.Nullable)1