diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityProperties.java b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityProperties.java index b57719f51adc61dcb0d4a43f33b90600c148e1b8..becb56a2397fffa323f005507463a586bdecc0cf 100644 --- a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityProperties.java +++ b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityProperties.java @@ -130,11 +130,16 @@ public class MySQLInsertEntityProperties extends MySQLTransaction if (property.getStatementStatus() == ReplacementStatus.REPLACEMENT) { // special treatment: swap value and id. This is part of the back-end specification for the - // representation of replacement. + // representation of replacement. The reason why this happens here (and + // not in the replacement class for instance) is that the original + // Property must not be changed for this. Otherwise we would have to + // change it back after the insertion or internally used replacement ids + // would be leaked. - // value should be the + // value is to be the id of the property which is being replaced fp.value = fp.id.toString(); + // id is to be the replacement id (an internally used/private id) fp.id = ((ReferenceValue) property.getValue()).getId().toInteger(); table = Table.reference_data; } else {