Skip to content

Java: Views and Projections #1916

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Java: Views and Projections #1916

wants to merge 6 commits into from

Conversation

MattSchur
Copy link
Contributor

@MattSchur MattSchur commented Jun 11, 2025

Introduces "Views and Projections" section with

  • Runtime Views
  • Write through Views

and documents some rules for write via path expressions in views.

Also shortens some headers to improve the readability in the navigation bar.

@MattSchur MattSchur requested a review from smahati as a code owner June 11, 2025 16:17
@MattSchur MattSchur changed the title Java: Write through Views Java: Views and Projections Jun 12, 2025
Select BooksWithLowStock where author = 'Kafka'
```

CAP Java provides two modes for resolving runtime views:
Copy link
Contributor

Choose a reason for hiding this comment

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

How developers should decide which mode to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can add recommendations later with experience from app development. Currently cte mode is the new default in 4.x with less limitations.

- The projection must not include [path expressions](../../cds/cql#path-expressions) using to-many associations.
- Projections targeting remote OData services must not include calculated elements.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can view include mixin associations or compositions? What will be writable then?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, these restrictions at least partially apply to the views in general, right? Are they described somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a section on deep write via views


Views and projections can be resolved for write operations if the following conditions are met:

- The view definition does not use any other clause than `columns` and `excluding` - `join`, `union` and `where` are not supported.
Copy link
Contributor

Choose a reason for hiding this comment

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

In the example above where is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where is supported in runtime views (on read), but currently not on write. The "Write through Views" section is not specific to runtime views but to views in general.

@MattSchur MattSchur requested a review from vmikhailenko June 12, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants