on 02-20-2023 2:36 PM
Hi,
I am trying use CAP to create Odata services on an existing database in HANA cloud. Since the tables exist my model has been created with annotation @cds.persistence.exists on entities.
However, since I want to test the solution in development (via sqlite), is it possible to generate the tables in SQLite only i.e. in development? Otherwise I am not able to test the application in development and have to deploy it always.
Regards,
Nitin
You can move the HANA specific @cds.persistence.exists
annotations into a separate folder. This is best practise in general if you need to distinguish database specific functionality, e.g. SAP HANA functions.
In order to avoid redundant model definitions, create a separate file db/hana/index.cds containing all @cds.persistence.exists
annotations, e.g.:
using { namespace } from '../foo';
annotate namespace.FOO1 with @cds.persistence.exists;
annotate namespace.FOO2 with @cds.persistence.exists;
Add the following to the cds configuration to your project:
"requires": {
"db-ext": {
"[production]" : { "model": "db/hana" }
}
}
cds watch will create the corresponding tables in the sqlite database as the development profile is used while cds build --production will not create the .hdbtable artifacts as the model folder db/hana is added to the list of compiled models setting the annotations for the corresponding entities.
For further details see https://github.com/SAP-samples/cloud-cap-samples/blob/main/fiori/package.json#L41. There is also a CodeTour (Database Functions Step8) for VSCode you can follow.
Regards,
Lothar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lothar,
How do you tell the service i.e. service.cds which path to pick the model from? /db/sqlite or /db/hana
It is not clear from the samples as well.
Regards,
Nitin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.