-
Notifications
You must be signed in to change notification settings - Fork 138
Java: Document @cds.java.ignore
#2097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b41b1bf
f3f1acc
9d192e4
9875027
6eceafb
650f130
a167d8b
4a4d7d1
f10c549
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if I understand the question.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this annotate statement usually located?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to provide an example use case, can ignore it and merge the PR if you'd like. @vmikhailenko
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding ignore is very exotic. I can remove whole clause about override to avoid confusion.