August 2021
Welcome to the release of CAP. Find the most noteworthy news and changes in the following sections.Multitenancy
Handlers for Asynchronous Subscription
Tenant creation and deletion are now called via CDS service TenantPersistenceService
, that applications can add handlers for:
@protocol:'rest'
service TenantPersistenceService {
type JSON {
// any json
}
action createTenant(tenantId: UUID, subscriptionData: JSON) returns String;
action deleteTenant(tenantId: UUID);
}
Learn more about the handler for asynchronous provisioning.
Correlation IDs for Tenant Operations
The propagation of correlation IDs to asynchronous tenant operations is now fixed. The correlation IDs in the log entries of asynchronous tenant operations now correctly match the correlation IDs of the request that triggered the operation.
New Capire Docs
CAP Release Schedule → This schedule gives a reliable basis for planning adoption accordingly.
New major versions of CAP will be released every 12 months, in April 2021, 2022, and so forth. Active CAP-based projects are strongly recommended to adopt new majors as soon as possible, as former releases will receive critical bug fixes only.
Minimalistic Logging Facade beta for Node.js → Learn more about out-of-the-box log formatting.
Best Practices for Node.js - Error Handling → This section gives a brief overview of common best practices.
Media Type Processing for CAP Java → This section describes how to process media streams in a custom event handler.
Testing CAP Java applications → This section describes some best practices and recommendations for testing CAP Java applications.
Observability for CAP Java → Presents a set of recommended tools that help to understand the current status of running CAP services.
Node.js Runtime
This release focuses on quality and incremental steps towards larger feature packages. See the changelog for more details.
Important Changes ❗️
You should take notice of the following changes, which may affect your project:
- Computed values are preserved during draft activate. That is, the values of properties that are annotated with
@Core.Computed
do not need to be recalculated when activating a draft, but are copied from the draft persistence to the active persistence. This change can be deactivated during a two-month grace period through compatibility feature flagcds.env.features.preserve_computed = false
.
Minor Additions
- Support for passing arguments for action and function implementations as objects.
- Support for OData's omit-values preference in
prefer
header. - Support for OData's ReadByKeyRestrictions annotation.
CDS Editors Speedup
The following applies to CDS editors in SAP Business Application Studio and Visual Studio Code.
New Default Validation Mode: ActiveEditorOnly
SAP Business Application Studio and VS Code have a new default CDS validation mode, ActiveEditorsOnly.
It further reduces necessary compilations to improve responsiveness. The new mode only keeps track of the active editor in focus. Other files, even open visible ones (split tabs), are first revalidated once they get focus again.
The new mode needs special client support, thus for other IDEs the default remains OpenEditorsOnly.
Learn more about this and other editor settings.
Graphical Dependency Analysis
A new command Visualize CDS file dependencies is available in SAP Business Application Studio and VS Code to get a better understanding of large models, for example, with hundreds of model files. Hovering over a node will show the number of files involved and the combined size of all involved files to get a rough understanding about the complexity and the compilation speed.
Use the command from the context menu on a folder or CDS file.
Learn more about this and other commands from the editor.
CDS Language & Compiler
Extend Array-Like Annotation Values
Usually annotations in an extend
overwrite already existing annotation values. If an existing annotation has an array-like value, use the new ellipsis syntax to add values into the array:
extend Books with @UI.LineItem: [
..., //> represents the existing array entires
{ Value: ISBN },
{ Value: pages }
] {
ISBN : String;
pages : Integer;
}
Learn more about Extend Array Annotations.
Doc Comments Are Translated to SAP HANA COMMENT
When generating output for deployment to SAP HANA, any entity's doc comments
/**
* I am the description for "Employee"
*/
entity Employees { ... }
are now translated to the HANA COMMENT
feature:
CREATE TABLE Employees (...) COMMENT 'I am the description for "Employee"'
Learn more about Doc Comments.
Java SDK
Important Changes ❗️
CDS Compiler v2 Enabled by Default
As of version 1.18.0, the CAP Java SDK uses the cds-dk 4 and the CDS Compiler v2. This applies for newly generated projects but also for existing projects that do not use a fixed version of the cds-dk in their pom.xml.
Learn more about using a specific cds-dk version.
Learn more about upgrading to Compiler v2.
Convenient Debug Logging with Spring Log Groups
The CAP Java SDK now defines Spring Boot Log Groups with logical names that you can use to turn on debug logging for certain areas of the CAP runtime. For example, to turn all logs regarding generated SQL statements, configure:
logging.level.com.sap.cds.persistence.sql: DEBUG
in your application configuration.
H2 Database by Default
Newly created projects now use the H2 database by default. H2 is the default database used in Spring Boot and thus requires very little configuration.
Returning Multiple Error Messages
The CAP Java SDK now collects all error messages for automatic input validation using the Messages API and does no longer abort the request processing on the first validation error. Applications can contribute additional errors using the Messages API in the Before
phase and are no longer required to explicitly call throwIfError()
in that case.
Session Context Variables in ON-conditions
You can now use session context variables such as $user.id
, $user.locale
, and $now
in ON-conditions of associations.
Updatable Views
Insert and update operations now also work on views having literals in the projection.
Structured Elements
Simple insert and select operations are now supported on structured elements.