Commit fb49d0fa authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Merge branch...

Merge branch '43-ri639-characteristic-hashcode-uses-mutable-fields-so-resource-updates-fail-with-a-duplicate-key' into 'develop'

Resolve "ri639 Characteristic.hashCode() uses mutable fields, so resource updates fail with a duplicate key"

See merge request !49
parents 191e4073 c8d232b9
Loading
Loading
Loading
Loading
Loading
+9 −2
Changes for src/main/java/org/etsi/osl/tmf/ri639/model/Characteristic.java: 9 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -162,10 +162,17 @@ public class Characteristic extends BaseRootNamedEntity {
				&& Objects.equals(this.type, characteristic.type);
	}

	/**
	 * Only the name is hashed: it is set before the characteristic is persisted and never changes
	 * afterwards. Characteristics live in Hibernate-managed Sets (e.g. Resource.resourceCharacteristic),
	 * and Hibernate finds what to insert by looking each element up in a hash-based snapshot. Hashing
	 * mutable state (value, id, which getId() fills in, or the lazy characteristicRelationship set) made
	 * an updated characteristic miss that lookup, so Hibernate re-inserted its existing join-table row
	 * and the update failed with a duplicate primary key.
	 */
	@Override
	public int hashCode() {
		return Objects.hash(id, name, valueType, characteristicRelationship, value, baseType, schemaLocation,
				type);
		return Objects.hash(name);
	}

	@Override