From 7365326018424d9a7e0530b4a528c329d8c1b7d2 Mon Sep 17 00:00:00 2001 From: Vladimir Mikhaylenko Date: Fri, 6 Feb 2026 15:54:12 +0100 Subject: [PATCH 1/3] Add magic tricks section --- java/change-tracking.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/java/change-tracking.md b/java/change-tracking.md index 4a96b28f66..0602a61f07 100644 --- a/java/change-tracking.md +++ b/java/change-tracking.md @@ -436,6 +436,44 @@ public class ChangeTrackingHandler implements EventHandler { You can query the change log entries via CQN statements, as usual. +## Tips and Tricks + +### Entities from imported services + +In general, Change Tracking expects that everything that needs change tracking is stored in the local database. +You might, however, need to model an association to the remote entity that, as a general rule, requires custom implementation. +The only possible option with associations like this is to track changes for its foreign key values. + +:::warning Configuration change required! +Enable [optimization for path expressions](/releases/2025/aug25#optimized-path-expressions). +::: + +Let's take the following model as an example: + +```cds +@cds.external: true +entity Remote { + key ID : UUID; + ... +} + +entity Local { + key ID : UUID; + toRemote : Association to Remote; +} +``` + +You model the association like this: + +```cds +entity Local { + key ID : UUID; + toRemote : Association to Remote @changelog: [toRemote.ID]; // [!code focus] +} +``` + +The entity's primary key is the only field you can use here, as rest of the association's target fields is not readable with standard persistence. The change log will contain one entry for the field `toRemote` just like the other associations with [human-readable values](#human-readable-values-for-associations). + ## Things to Consider when Using Change Tracking - Consider the storage costs of the change log. The change log can grow very fast and can consume a lot of space From 8e1874f349835b24ab28666366d3cd9a5c71495b Mon Sep 17 00:00:00 2001 From: Vladimir Mikhaylenko Date: Mon, 9 Feb 2026 11:10:19 +0100 Subject: [PATCH 2/3] . --- java/change-tracking.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/java/change-tracking.md b/java/change-tracking.md index 0602a61f07..a1d08d19df 100644 --- a/java/change-tracking.md +++ b/java/change-tracking.md @@ -438,9 +438,9 @@ You can query the change log entries via CQN statements, as usual. ## Tips and Tricks -### Entities from imported services +### Entities from Remote Services -In general, Change Tracking expects that everything that needs change tracking is stored in the local database. +In general, Change Tracking expects that everything is stored in the local database. You might, however, need to model an association to the remote entity that, as a general rule, requires custom implementation. The only possible option with associations like this is to track changes for its foreign key values. @@ -474,6 +474,8 @@ entity Local { The entity's primary key is the only field you can use here, as rest of the association's target fields is not readable with standard persistence. The change log will contain one entry for the field `toRemote` just like the other associations with [human-readable values](#human-readable-values-for-associations). +If you need a custom identifier, it is up to you to implement in a custom handler. + ## Things to Consider when Using Change Tracking - Consider the storage costs of the change log. The change log can grow very fast and can consume a lot of space From 4b6eb05b565ad6fda3bb7d57e4020e6570d146af Mon Sep 17 00:00:00 2001 From: Vladimir Mikhaylenko Date: Mon, 9 Feb 2026 11:11:38 +0100 Subject: [PATCH 3/3] less words --- java/change-tracking.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/java/change-tracking.md b/java/change-tracking.md index a1d08d19df..b81f9c8a54 100644 --- a/java/change-tracking.md +++ b/java/change-tracking.md @@ -440,9 +440,8 @@ You can query the change log entries via CQN statements, as usual. ### Entities from Remote Services -In general, Change Tracking expects that everything is stored in the local database. -You might, however, need to model an association to the remote entity that, as a general rule, requires custom implementation. -The only possible option with associations like this is to track changes for its foreign key values. +Change Tracking expects that everything is stored in the local database. +If you need to model an association to the remote entity, the only possible option is to track changes for its foreign key. :::warning Configuration change required! Enable [optimization for path expressions](/releases/2025/aug25#optimized-path-expressions).