/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object key = null; if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { addToCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { removeFromCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ @Override public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object key = null; if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { addToCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { removeFromCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ @Override public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object key = null; if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { addToCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { removeFromCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }
@Override public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord){ int changeType = event.getChangeType(); if (changeType == CollectionChangeEvent.ADD) { super.recordAddToCollectionInChangeRecord(changeSet, collectionChangeRecord); } else if (changeType == CollectionChangeEvent.REMOVE) { super.recordRemoveFromCollectionInChangeRecord(changeSet, collectionChangeRecord); } else { throw ValidationException.wrongCollectionChangeEventType(changeType); } OrderedChangeObject orderedChangeObject = new OrderedChangeObject(changeType, event.getIndex(), changeSet, event.getNewValue()); collectionChangeRecord.getOrderedChangeObjectList().add(orderedChangeObject); }
public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord){ int changeType = event.getChangeType(); if (changeType == CollectionChangeEvent.ADD) { super.recordAddToCollectionInChangeRecord(changeSet, collectionChangeRecord); } else if (changeType == CollectionChangeEvent.REMOVE) { super.recordRemoveFromCollectionInChangeRecord(changeSet, collectionChangeRecord); } else { throw ValidationException.wrongCollectionChangeEventType(changeType); } OrderedChangeObject orderedChangeObject = new OrderedChangeObject(changeType, event.getIndex(), changeSet, event.getNewValue()); collectionChangeRecord.getOrderedChangeObjectList().add(orderedChangeObject); }
@Override public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord){ int changeType = event.getChangeType(); if (changeType == CollectionChangeEvent.ADD) { super.recordAddToCollectionInChangeRecord(changeSet, collectionChangeRecord); } else if (changeType == CollectionChangeEvent.REMOVE) { super.recordRemoveFromCollectionInChangeRecord(changeSet, collectionChangeRecord); } else { throw ValidationException.wrongCollectionChangeEventType(changeType); } OrderedChangeObject orderedChangeObject = new OrderedChangeObject(changeType, event.getIndex(), changeSet, event.getNewValue()); collectionChangeRecord.getOrderedChangeObjectList().add(orderedChangeObject); }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object value = event.getNewValue(); if (event.getChangeType() == CollectionChangeEvent.ADD) { simpleAddToCollectionChangeRecord(value, event.getIndex(), event.isSet(), changeSet, uow); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { simpleRemoveFromCollectionChangeRecord(value, event.getIndex(), event.isSet(), changeSet, uow); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event !=null && event.getNewValue() != null) { Object newValue = event.getNewValue(); ClassDescriptor descriptor; //PERF: Use referenceDescriptor if it does not have inheritance if (!getReferenceDescriptor().hasInheritance()) { descriptor = getReferenceDescriptor(); } else { descriptor = uow.getDescriptor(newValue); } newValue = descriptor.getObjectBuilder().unwrapObject(newValue, uow); ObjectChangeSet changeSetToAdd = descriptor.getObjectBuilder().createObjectChangeSet(newValue, (UnitOfWorkChangeSet)changeSet.getUOWChangeSet(), uow); CollectionChangeRecord collectionChangeRecord = (CollectionChangeRecord)changeSet.getChangesForAttributeNamed(this.getAttributeName()); if (collectionChangeRecord == null) { collectionChangeRecord = new CollectionChangeRecord(changeSet); collectionChangeRecord.setAttribute(getAttributeName()); collectionChangeRecord.setMapping(this); changeSet.addChange(collectionChangeRecord); } if(!collectionChangeRecord.isDeferred()) { this.containerPolicy.recordUpdateToCollectionInChangeRecord(event, changeSetToAdd, collectionChangeRecord); } } }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event !=null && event.getNewValue() != null) { Object newValue = event.getNewValue(); ClassDescriptor descriptor; //PERF: Use referenceDescriptor if it does not have inheritance if (!getReferenceDescriptor().hasInheritance() && !getReferenceDescriptor().hasTablePerClassPolicy()) { descriptor = getReferenceDescriptor(); } else { descriptor = uow.getDescriptor(newValue); } newValue = descriptor.getObjectBuilder().unwrapObject(newValue, uow); ObjectChangeSet changeSetToAdd = descriptor.getObjectBuilder().createObjectChangeSet(newValue, (UnitOfWorkChangeSet)changeSet.getUOWChangeSet(), uow); CollectionChangeRecord collectionChangeRecord = (CollectionChangeRecord)changeSet.getChangesForAttributeNamed(this.getAttributeName()); if (collectionChangeRecord == null) { collectionChangeRecord = new CollectionChangeRecord(changeSet); collectionChangeRecord.setAttribute(getAttributeName()); collectionChangeRecord.setMapping(this); changeSet.addChange(collectionChangeRecord); } if(!collectionChangeRecord.isDeferred()) { this.containerPolicy.recordUpdateToCollectionInChangeRecord(event, changeSetToAdd, collectionChangeRecord); } } }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event !=null && event.getNewValue() != null) { Object newValue = event.getNewValue(); ClassDescriptor descriptor; //PERF: Use referenceDescriptor if it does not have inheritance if (!getReferenceDescriptor().hasInheritance() && !getReferenceDescriptor().hasTablePerClassPolicy()) { descriptor = getReferenceDescriptor(); } else { descriptor = uow.getDescriptor(newValue); } newValue = descriptor.getObjectBuilder().unwrapObject(newValue, uow); ObjectChangeSet changeSetToAdd = descriptor.getObjectBuilder().createObjectChangeSet(newValue, (UnitOfWorkChangeSet)changeSet.getUOWChangeSet(), uow); CollectionChangeRecord collectionChangeRecord = (CollectionChangeRecord)changeSet.getChangesForAttributeNamed(this.getAttributeName()); if (collectionChangeRecord == null) { collectionChangeRecord = new CollectionChangeRecord(changeSet); collectionChangeRecord.setAttribute(getAttributeName()); collectionChangeRecord.setMapping(this); changeSet.addChange(collectionChangeRecord); } if(!collectionChangeRecord.isDeferred()) { this.containerPolicy.recordUpdateToCollectionInChangeRecord(event, changeSetToAdd, collectionChangeRecord); } } }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ @Override public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object value = event.getNewValue(); if (event.getChangeType() == CollectionChangeEvent.ADD) { simpleAddToCollectionChangeRecord(value, event.getIndex(), event.isSet(), changeSet, uow, event.isChangeApplied()); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { simpleRemoveFromCollectionChangeRecord(value, event.getIndex(), event.isSet(), changeSet, uow, event.isChangeApplied()); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ @Override public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object value = event.getNewValue(); if (event.getChangeType() == CollectionChangeEvent.ADD) { simpleAddToCollectionChangeRecord(value, event.getIndex(), event.isSet(), changeSet, uow, event.isChangeApplied()); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { simpleRemoveFromCollectionChangeRecord(value, event.getIndex(), event.isSet(), changeSet, uow, event.isChangeApplied()); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }