{"ref":"capability:hana-native-artifacts","page":"/capabilities/hana-native-artifacts","json":"/capabilities/hana-native-artifacts.json","generated":"2026-10-26","drafted_with_ai":true,"entity":{"id":"hana-native-artifacts","name":"Native SAP HANA artifacts","domain":"data-and-persistence","ecosystems":["cap"],"universal":false,"description":"Using native SAP HANA database objects alongside an application’s generated data model, including objects and database features the modelling layer cannot express. Choosing a database is [database connectors](capability:database-connectors); changing an existing schema is [schema evolution](capability:schema-evolution).","short":"Using native SAP HANA database objects beside the generated model","core_coverage":{"state":"core-only","assessed_at":"2026-09-27","what_core_does":"Built in: an entity annotated `@cds.persistence.exists` is a facade for a table, view, table function or calculation view that already exists on the database, with `@cds.persistence.udf` and `@cds.persistence.calcview` as hints for the SQL it renders, parameters on views since @sap/cds 3.4.1, and `hana.*` types for a ported SAP HANA CDS model. `@sql.prepend` and `@sql.append` insert a native clause the compiler does not evaluate. Whatever lives in `db/src`, an `.hdbindex`, an `.hdbsynonym`, an `.hdbtable`, is copied by `cds build` into the deployment untouched, so an object from another HDI container enters through a synonym and the grants HDI needs. [cds-federation-synonyms](artifact:cap-js-cds-federation-synonyms) generates those synonyms for the CAP-to-CAP case.","where_it_stops":"At the file. A native object is designed in HDI's own formats and deployed by [@sap/hdi-deploy](artifact:sap-hdi-deploy); the compiler checks neither a native clause nor a facade's signature against the object it stands for, and a function with table-like parameters is not supported. Cross-container access needs the grantor's service key and the role grants set up outside the model, which the one sample here does by hand. On any database but SAP HANA there is no HDI and none of this applies.","sources":[{"url":"https://cap.cloud.sap/docs/guides/databases/hana-native","title":"Using Native HANA Artifacts — capire","checked":"2026-09-27","quote":"Add the annotation @cds.persistence.exists to tell CDS that this object already exists on the database and must not be generated."},{"url":"https://cap.cloud.sap/docs/guides/databases/hana-native","title":"Using Native HANA Artifacts — capire","checked":"2026-09-27","quote":"To access database artifacts residing in other HDI containers, you need the permissions granted for that container and you need to introduce them into your own container using synonyms."},{"url":"https://cap.cloud.sap/docs/guides/databases/hana-native","title":"Using Native HANA Artifacts — capire","checked":"2026-09-27","quote":"This folder stays untouched during the cds build and the content is copied over to the gen/db/src folder during the build."},{"url":"https://cap.cloud.sap/docs/guides/databases/hana-native","title":"Using Native HANA Artifacts — capire","checked":"2026-09-27","quote":"Parameters can be added to the CDS model starting with @sap/cds 3.4.1 / @sap/cds-compiler 1.7.1."},{"url":"https://cap.cloud.sap/docs/guides/databases/hana-native","title":"Using Native HANA Artifacts — capire","checked":"2026-09-27","quote":"@cds.persistence.udf to specify that the facade entity represents a user-defined function"},{"url":"https://cap.cloud.sap/docs/guides/databases/hana-native","title":"Using Native HANA Artifacts — capire","checked":"2026-09-27","quote":"Functions with table-like input parameters are not supported."},{"url":"https://cap.cloud.sap/docs/guides/databases/hana-native","title":"Using Native HANA Artifacts — capire","checked":"2026-09-27","quote":"The following SAP HANA-specific data types are primarily intended for porting existing SAP HANA CDS models into the CAP domain if the old SAP HANA types must be preserved in the existing database tables."},{"url":"https://cap.cloud.sap/docs/guides/databases/hana","title":"Using SAP HANA Cloud for Production — capire","checked":"2026-09-27","quote":"Not all clauses supported by SQL can directly be written in CDL syntax. To use native database clauses also in a CAP CDS model, you can provide arbitrary SQL snippets with the annotations @sql.prepend and @sql.append."},{"url":"https://cap.cloud.sap/docs/guides/databases/hana","title":"Using SAP HANA Cloud for Production — capire","checked":"2026-09-27","quote":"Any snippet is taken as is and inserted into the TABLE statement and the corresponding ALTER statement. The deployment fails in case of syntax errors."},{"url":"https://cap.cloud.sap/docs/guides/databases/hana","title":"Using SAP HANA Cloud for Production — capire","checked":"2026-09-27","quote":"In addition to the generated HDI artifacts, you can add custom ones by adding according files to folder db/src."}]},"changed_in":[{"version":"@sap/cds 9.0.2","date":"2025-06-02","applies_to":{"ecosystems":["cap"],"flavors":["node"]},"what_changed":"CDS associations are no longer reflected as native SAP HANA associations (the WITH ASSOCIATIONS clause) in generated tables and views by default, because CAP does not need them and their validation slowed HDI deployments and introduced indirect dependencies between objects. Dated from the first 9.0 release published on npm, 9.0.2.","invalidates":"Native HANA code, a calculation view or an SQLScript procedure, that navigated a CDS association on the database through the native association and expects it to still be there after an upgrade.","source":{"url":"https://cap.cloud.sap/docs/guides/databases/hana","title":"Using SAP HANA Cloud for Production — capire","checked":"2026-09-27","quote":"by default no native HANA associations are created anymore starting with CAP 9."}}],"history":[{"date":"2026-09-27","field":"id","from":"none","to":"hana-native-artifacts","reason":"Proposed by the capire audit of 2026-09-27 with medium confidence: existing database objects used from a CDS model, custom HDI artifacts and cross-container synonyms are documented in two guides and owned by no capability; database-connectors is the driver, schema-evolution the migration. Two blog entries about cross-container synonyms had been filed under database-connectors for want of a better slot. Created by the maintainer's decision."},{"date":"2026-10-17","field":"description","from":"Using a database object CDS did not generate from the model, an existing table, a view with parameters, a table function, a calculation view or a table in another HDI container, and shipping the design-time files CDS cannot express, an index, a synonym, a native clause, in the same deployment. Distinct from [database connectors](capability:database-connectors), which is which database the model runs on, and from [schema evolution](capability:schema-evolution), which is getting a model change into data that already exists.","to":"Using native SAP HANA database objects alongside an application’s generated data model, including objects and database features the modelling layer cannot express. Choosing a database is [database connectors](capability:database-connectors); changing an existing schema is [schema evolution](capability:schema-evolution).","reason":"Keep the technology that defines the concern in the default; move implementation detail to framing_by_ecosystem.cap. Maintainer-requested scope audit."}],"drafted_with_ai":true,"framing_by_ecosystem":{"cap":{"description":"Using a database object CDS did not generate from the model, an existing table, a view with parameters, a table function, a calculation view or a table in another HDI container, and shipping the design-time files CDS cannot express, an index, a synonym, a native clause, in the same deployment. Distinct from [database connectors](capability:database-connectors), which is which database the model runs on, and from [schema evolution](capability:schema-evolution), which is getting a model change into data that already exists."}}},"sap_delivery":{"door":"cap","all":{"built_in":[{"ref":"artifact:sap-cds","name":"@sap/cds","json":"/artifacts/sap-cds.json"}],"documented_pattern":[],"announced":[],"packages":[{"ref":"artifact:sap-cds-dk","name":"@sap/cds-dk","json":"/artifacts/sap-cds-dk.json"},{"ref":"artifact:sap-hdi-deploy","name":"@sap/hdi-deploy","json":"/artifacts/sap-hdi-deploy.json"},{"ref":"artifact:cap-js-cds-federation-synonyms","name":"cds-federation-synonyms","json":"/artifacts/cap-js-cds-federation-synonyms.json"}]},"by_flavor":{"node":{"built_in":[{"ref":"artifact:sap-cds","name":"@sap/cds","json":"/artifacts/sap-cds.json"}],"documented_pattern":[],"announced":[],"packages":[{"ref":"artifact:sap-cds-dk","name":"@sap/cds-dk","json":"/artifacts/sap-cds-dk.json"},{"ref":"artifact:sap-hdi-deploy","name":"@sap/hdi-deploy","json":"/artifacts/sap-hdi-deploy.json"},{"ref":"artifact:cap-js-cds-federation-synonyms","name":"cds-federation-synonyms","json":"/artifacts/cap-js-cds-federation-synonyms.json"}]},"java":null}},"edges":{"use_cases":[],"shared_tasks":[],"related_tasks":[],"options":[{"ref":"artifact:sap-cds","name":"@sap/cds","json":"/artifacts/sap-cds.json","ecosystem":"cap","origin_ring":"sap-official"},{"ref":"artifact:sap-cds-dk","name":"@sap/cds-dk","json":"/artifacts/sap-cds-dk.json","ecosystem":"cap","origin_ring":"sap-official"},{"ref":"artifact:sap-hdi-deploy","name":"@sap/hdi-deploy","json":"/artifacts/sap-hdi-deploy.json","ecosystem":"cap","origin_ring":"sap-official"},{"ref":"artifact:cap-js-cds-federation-synonyms","name":"cds-federation-synonyms","json":"/artifacts/cap-js-cds-federation-synonyms.json","ecosystem":"cap","origin_ring":"sap-official"},{"ref":"artifact:sap-samples-hana-developer-cli-tool-example","name":"SAP-samples/hana-developer-cli-tool-example","json":"/artifacts/sap-samples-hana-developer-cli-tool-example.json","ecosystem":"btp","origin_ring":"sap-official"}],"samples":[{"ref":"artifact:miyasuta-cap-cross-container","name":"cap-cross-container","json":"/artifacts/miyasuta-cap-cross-container.json"}],"explained_by":[{"ref":"content:connecting-two-sap-cap-projects-without-duplicating-your-data","name":"Connecting Two SAP CAP Projects Without Duplicating Your Data","json":"/content/connecting-two-sap-cap-projects-without-duplicating-your-data.json"},{"ref":"content:how-to-share-tables-across-different-cap-projects","name":"How to share tables across different CAP projects","json":"/content/how-to-share-tables-across-different-cap-projects.json"}],"normative_context":[]}}