Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions java/cds-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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:

```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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably lacking modelling knowledge to understand this. How do I set the context where this should be used, for example a service? I guess it's not globally overridden, or?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I understand the question.

Copy link
Contributor

@renejeglinsky renejeglinsky Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this annotate statement usually located?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside the service where annotation is overridden.

```

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

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.
Expand Down