Project

General

Profile

bug #7155

Updated by Andreas Kohlbecker over 6 years ago

The `equals()` as implemented in `VersionableEntity` is just a copy of the `equals` in `CdmBase`. It does not implement further functionality except of a null check of the UUID. That is, it completely misses comparing the updated timestamps. This however is crucial, since otherwise for example an older entity derived from the auditing tables would be equal to the current version of the entity. 

 I stumbled over this in the context of the vaadin `com.vaadin.ui.AbstractField.setValue(T newFieldValue, boolean repaintIsNotNeeded, boolean ignoreReadOnly)` method in which the `equals` comparison is used to determine if the supplied `newFieldValue` is different from the current field value. Since `VersionableEntity.equals()` is ignoring the `updated` timestamp updated cdm entities can not be set as field value in order to update the UI with the new persistence state. The obvious workaround to first set the field value to `null` is awkward and not without nasty side effects. 

 Most lines of the `VersionableEntity.equals()` implementation can furthermore be replaced by a `super.equals()` call which would make this method much more clear. 
 If we won't change the `VersionableEntity.equals()` we should remove it, since it does exactly the same as the method it overrides.

Back