From b41b1bf1b2fd1b6a6dc09ca153971bb2f9ce9ffc Mon Sep 17 00:00:00 2001 From: Vladimir Mikhaylenko Date: Tue, 26 Aug 2025 13:33:47 +0200 Subject: [PATCH 1/7] Document typed query results in codegen --- java/developing-applications/building.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/developing-applications/building.md b/java/developing-applications/building.md index 1487f33f12..2388695638 100644 --- a/java/developing-applications/building.md +++ b/java/developing-applications/building.md @@ -483,6 +483,10 @@ Other options in this goal enable or disable certain features that change the wa The method `getService()` in generated [event-specific Event Context interfaces](../event-handlers/#eventcontext) is overridden to return the typed service interface instead of the generic `Service` type. +- [`linkedInterfaces`] + + This switch extends the generated interfaces so they support typed query results of type `CdsResult`. + :::warning Check migration guides! In major releases of CAP Java, some of these switches can be made the new default and some other switches might be removed. This might introduce compile errors in your application that needs to be fixed. From f3f1acc9aeb44a40d382c9cdc0c56ab5e00c645b Mon Sep 17 00:00:00 2001 From: Vladimir Mikhaylenko Date: Tue, 26 Aug 2025 13:36:18 +0200 Subject: [PATCH 2/7] Add link --- java/developing-applications/building.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/developing-applications/building.md b/java/developing-applications/building.md index 2388695638..9514c5d814 100644 --- a/java/developing-applications/building.md +++ b/java/developing-applications/building.md @@ -483,7 +483,7 @@ Other options in this goal enable or disable certain features that change the wa The method `getService()` in generated [event-specific Event Context interfaces](../event-handlers/#eventcontext) is overridden to return the typed service interface instead of the generic `Service` type. -- [`linkedInterfaces`] +- [`linkedInterfaces`](/java/assets/cds-maven-plugin-site/generate-mojo.html#linkedInterfaces) This switch extends the generated interfaces so they support typed query results of type `CdsResult`. From 9875027d2021a45550ca8608d7adb70b189edb6e Mon Sep 17 00:00:00 2001 From: Vladimir Mikhaylenko Date: Wed, 17 Sep 2025 15:35:29 +0200 Subject: [PATCH 3/7] java: Document `@cds.java.ignore` --- java/cds-data.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/java/cds-data.md b/java/cds-data.md index 068f3d1bde..82bd63f76c 100644 --- a/java/cds-data.md +++ b/java/cds-data.md @@ -620,6 +620,52 @@ Note, that the propagated annotation `@cds.java.name` creates attribute and meth This feature requires version 8.2.0 of the [CDS Command Line Interface](/tools/cds-cli). ::: +#### Excluding Elements + +You can exclude elements from accessor interfaces with the annotation `@cds.java.ignore`. + +For example, you can exclude an element from the entity like this: + +```cds +namespace my.bookshop; + +entity Books { + key ID : Integer; + title : localized String; + stock : Integer; + @cds.java.ignore + ignored : String; +} +``` + +This will yield an interface that has no methods for the attribute `ignored`. + +On the service level, you can exclude elements from projections as well as operations and their arguments like this: + +```cds +service CatalogService { + entity Books as + projection on my.Books { + ID, + @cds.java.ignore title, + stock, + ignored + } + actions { + @cds.java.ignore action act(@cds.java.ignore arg: String); + function func(arg: String, @cds.java.ignore ignored: String) returns String; + } +} +``` + +This annotation propagates across projections and they also omit the ignored elements. This can be overridden with the following annotation: + +```cds +annotate Books:ignored with @cds.java.ignore: false; +``` + +If you want to exclude set of entities, prefer [filters](/java/developing-applications/building#filter-for-cds-entities) for code generator. + #### Entity Inheritance in Java In CDS models it is allowed to extend a definition (for example, of an entity) with one or more named [aspects](../cds/cdl#aspects). The aspect allows to define elements or annotations that are common to all extending definitions in one place. From 6eceafbb255231423155e34a431b9520df22f820 Mon Sep 17 00:00:00 2001 From: Vladimir Mikhaylenko Date: Wed, 17 Sep 2025 15:50:35 +0200 Subject: [PATCH 4/7] Revert unrelated stuff --- java/developing-applications/building.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/java/developing-applications/building.md b/java/developing-applications/building.md index 871f1622d0..9514c5d814 100644 --- a/java/developing-applications/building.md +++ b/java/developing-applications/building.md @@ -398,10 +398,6 @@ You configure this goal just like any other Maven plugin via its configuration o Each time your application is built, these interfaces are regenerated. By default, they are excluded from your version control. -### Typed Results - -Set the [`linkedInterfaces`](/java/assets/cds-maven-plugin-site/generate-mojo.html#linkedInterfaces) option to link the generated [query builder interfaces](../working-with-cql/query-api#concepts) to the [data accessor interfaces](../cds-data#typed-access) for queries with [typed results](../working-with-cql/query-execution#typed-result-processing). - ### Package for Generated Code The option [`basePackage`](/java/assets/cds-maven-plugin-site/generate-mojo.html#basePackage) can be used to specify a base package prefix for generated code. The suffix package structure will reflect namespaces defined in your CDS model. From 650f1308f9c1b080c27f5c2c275ff6bdb981d487 Mon Sep 17 00:00:00 2001 From: Vladimir Mikhaylenko Date: Wed, 17 Sep 2025 15:52:00 +0200 Subject: [PATCH 5/7] Revert unrelated stuff --- java/developing-applications/building.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/developing-applications/building.md b/java/developing-applications/building.md index 9514c5d814..cdddc06dcf 100644 --- a/java/developing-applications/building.md +++ b/java/developing-applications/building.md @@ -398,6 +398,10 @@ You configure this goal just like any other Maven plugin via its configuration o Each time your application is built, these interfaces are regenerated. By default, they are excluded from your version control. +### Typed Results + +Set the [`linkedInterfaces`](/java/assets/cds-maven-plugin-site/generate-mojo.html#linkedInterfaces) option to link the generated [query builder interfaces](../working-with-cql/query-api#concepts) to the [data accessor interfaces](../cds-data#typed-access) for queries with [typed results](../working-with-cql/query-execution#typed-result-processing). + ### Package for Generated Code The option [`basePackage`](/java/assets/cds-maven-plugin-site/generate-mojo.html#basePackage) can be used to specify a base package prefix for generated code. The suffix package structure will reflect namespaces defined in your CDS model. @@ -483,10 +487,6 @@ Other options in this goal enable or disable certain features that change the wa The method `getService()` in generated [event-specific Event Context interfaces](../event-handlers/#eventcontext) is overridden to return the typed service interface instead of the generic `Service` type. -- [`linkedInterfaces`](/java/assets/cds-maven-plugin-site/generate-mojo.html#linkedInterfaces) - - This switch extends the generated interfaces so they support typed query results of type `CdsResult`. - :::warning Check migration guides! In major releases of CAP Java, some of these switches can be made the new default and some other switches might be removed. This might introduce compile errors in your application that needs to be fixed. From a167d8b55dd3e4ad2f99dff7e8bd6b25a4295fcc Mon Sep 17 00:00:00 2001 From: Mahati Shankar <93712176+smahati@users.noreply.github.com> Date: Mon, 22 Sep 2025 10:46:38 +0200 Subject: [PATCH 6/7] Update java/cds-data.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: René Jeglinsky --- java/cds-data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/cds-data.md b/java/cds-data.md index 82bd63f76c..40648e2c6e 100644 --- a/java/cds-data.md +++ b/java/cds-data.md @@ -664,7 +664,7 @@ This annotation propagates across projections and they also omit the ignored ele annotate Books:ignored with @cds.java.ignore: false; ``` -If you want to exclude set of entities, prefer [filters](/java/developing-applications/building#filter-for-cds-entities) for code generator. +If you want to exclude a set of entities, prefer [filters](/java/developing-applications/building#filter-for-cds-entities) for the code generator. #### Entity Inheritance in Java From 4a4d7d1632acbe84c18af937d44ea96eca9d4ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20G=C3=B6rler?= Date: Wed, 22 Oct 2025 09:28:38 +0200 Subject: [PATCH 7/7] Update java/cds-data.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: René Jeglinsky --- java/cds-data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/cds-data.md b/java/cds-data.md index 40648e2c6e..a3bab55649 100644 --- a/java/cds-data.md +++ b/java/cds-data.md @@ -638,7 +638,7 @@ entity Books { } ``` -This will yield an interface that has no methods for the attribute `ignored`. +This provides an interface that has no methods for the attribute `ignored`. On the service level, you can exclude elements from projections as well as operations and their arguments like this: