From 5d5ea96303228064c854194d1ce60b7c4ab298d7 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Wed, 16 Aug 2023 11:24:17 +0200
Subject: [PATCH] WIP: MAINT: refactor retrieve properties (move backend-logic
 to backend)

---
 .../MySQL/MySQLInsertEntityProperties.java               | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

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 b57719f5..becb56a2 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 {
-- 
GitLab