public void internalPropertyChange(PropertyChangeEvent evt) {
if (evt.getNewValue() == evt.getOldValue()) {
return;
}
DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(evt.getPropertyName());
//Bug#4127952 Throw an exception indicating there is no mapping for the property name.
if (mapping == null) {
throw ValidationException.wrongPropertyNameInChangeEvent(owner.getClass(), evt.getPropertyName());
}
if (mapping instanceof AbstractDirectMapping || mapping instanceof AbstractTransformationMapping) {
//If both newValue and oldValue are null, or newValue is not null and newValue equals oldValue, don't build ChangeRecord
if (((evt.getNewValue() == null) && (evt.getOldValue() == null)) || ((evt.getNewValue() != null) && (evt.getNewValue()).equals(evt.getOldValue()))) {
return;
}
}
super.internalPropertyChange(evt);
if (uow.getUnitOfWorkChangeSet() == null) {
uow.setUnitOfWorkChangeSet(new UnitOfWorkChangeSet(uow));
}
if (objectChangeSet == null) {//only null if new or if in a new UOW
//add to tracker list to prevent GC of clone if using weak references
//put it in here so that it only occurs on the 1st change for a particular UOW
uow.addToChangeTrackedHardList(owner);
objectChangeSet = getDescriptor().getObjectBuilder().createObjectChangeSet(owner, (UnitOfWorkChangeSet) uow.getUnitOfWorkChangeSet(), false, uow);
}
if (evt.getClass().equals(ClassConstants.PropertyChangeEvent_Class)) {
mapping.updateChangeRecord(evt.getSource(), evt.getNewValue(), evt.getOldValue(), objectChangeSet, getUnitOfWork());
} else if (evt.getClass().equals(ClassConstants.CollectionChangeEvent_Class) || (evt.getClass().equals(ClassConstants.MapChangeEvent_Class))) {
mapping.updateCollectionChangeRecord((CollectionChangeEvent)evt, objectChangeSet, getUnitOfWork());
} else {
throw ValidationException.wrongChangeEvent(evt.getClass());
}
}