Search in sources :

Example 11 with DirectCollectionChangeRecord

use of org.eclipse.persistence.internal.sessions.DirectCollectionChangeRecord in project eclipselink by eclipse-ee4j.

the class DirectCollectionMapping method updateChangeRecord.

/**
 * INTERNAL:
 * Either create a new change record or update with the new value.  This is used
 * by attribute change tracking.
 * Specifically in a collection mapping this will be called when the customer
 * Set a new collection.  In this case we will need to mark the change record
 * with the new and the old versions of the collection.
 * And mark the ObjectChangeSet with the attribute name then when the changes are calculated
 * force a compare on the collections to determine changes.
 */
@Override
public void updateChangeRecord(Object clone, Object newValue, Object oldValue, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow) {
    DirectCollectionChangeRecord collectionChangeRecord = (DirectCollectionChangeRecord) objectChangeSet.getChangesForAttributeNamed(this.getAttributeName());
    if (collectionChangeRecord == null) {
        collectionChangeRecord = new DirectCollectionChangeRecord(objectChangeSet);
        collectionChangeRecord.setAttribute(getAttributeName());
        collectionChangeRecord.setMapping(this);
        objectChangeSet.addChange(collectionChangeRecord);
    }
    collectionChangeRecord.setIsDeferred(true);
    objectChangeSet.deferredDetectionRequiredOn(getAttributeName());
    if (collectionChangeRecord.getOriginalCollection() == null) {
        collectionChangeRecord.recreateOriginalCollection(oldValue, uow);
    }
    collectionChangeRecord.setLatestCollection(newValue);
}
Also used : DirectCollectionChangeRecord(org.eclipse.persistence.internal.sessions.DirectCollectionChangeRecord)

Aggregations

DirectCollectionChangeRecord (org.eclipse.persistence.internal.sessions.DirectCollectionChangeRecord)11 IndirectList (org.eclipse.persistence.indirection.IndirectList)4 ObjectChangeSet (org.eclipse.persistence.internal.sessions.ObjectChangeSet)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 IdentityHashMap (java.util.IdentityHashMap)3 List (java.util.List)3 ContainerPolicy (org.eclipse.persistence.internal.queries.ContainerPolicy)3 OrderedListContainerPolicy (org.eclipse.persistence.internal.queries.OrderedListContainerPolicy)3 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Set (java.util.Set)2 ValueHolder (org.eclipse.persistence.indirection.ValueHolder)2 DescriptorIterator (org.eclipse.persistence.internal.descriptors.DescriptorIterator)2 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)2 AbstractRecord (org.eclipse.persistence.internal.sessions.AbstractRecord)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 Map (java.util.Map)1 ChangeTracker (org.eclipse.persistence.descriptors.changetracking.ChangeTracker)1 CollectionChangeEvent (org.eclipse.persistence.descriptors.changetracking.CollectionChangeEvent)1