This section describes how to configure applications.
For local development, SQLite can be configured to run in-memory or in the file-based mode. Below you find the configuration information for the respective option.
The database content is stored in a file,
sqlite.db as in the following example. Since the schema is initialized using
cds deploy command, the initialization mode is set to
--- spring: profiles: sqlite datasource: url: "jdbc:sqlite:sqlite.db" driver-class-name: org.sqlite.JDBC initialization-mode: never hikari: maximum-pool-size: 1
The database content is stored in-memory only. The schema initialization is handled by Spring by executing the
schema.sql script. Hence, the initialization mode is set to
--- spring: profiles: default datasource: url: "jdbc:sqlite:file::memory:?cache=shared" driver-class-name: org.sqlite.JDBC initialization-mode: always hikari: maximum-pool-size: 1
Database Support in Java
This section describes the different databases, which are supported by CAP Java SDK and any differences between them with respect to CAP features. There’s out of the box support for SAP HANA with CAP currently as well as SQLite. However, it’s important to note that SQLite isn’t an enterprise grade database and is recommended for nonproductive use like local development or CI tests only.
CAP doesn’t support PostgreSQL out of the box. However, CAP Java SDK has been tested against the PostgreSQL database (
version 9.6.15) and supports in general most of the features of CAP. Nevertheless, find here a list of unsupported features/differences:
- CDS doesn’t yet support PostgreSQL specific database schema generation.
- There’s no support for Schema Evolution for PostgreSQL.
- Localization is supported just as in SQLite:
- PostgreSQL doesn’t support the SESSION_CONTEXT method to dynamically determine the locale from a connection.
cdscreates two SQL views for the languages German and French by default, to be able to determine the locale at runtime.
- The sort order of any query on PostgreSQL will behave as configured on the database.
CAP supports SQLite out of the box. When working with Java, it’s recommended to use SQLite only for development and testing purposes. There’s no production support for SQLite from CAP.
CAP does support most of the major features on SQLite, although there are a few shortcomings that are listed below.
- Localization is only supported currently for ‘de’, ‘fr’ and a default locale. We’ll in the near future provide support for all other locales.
- Any views generated for SQLite are read-only by default, inserting records can only happen with a one to one projection.
- SQLite has only limited support for concurrent database access. You’re advised to limit the connection pool to 1 as shown above (parameter
maximum-pool-size: 1), which effectively serializes all database transactions.
- The predicate function
containsis supported. However, the search for characters in the word or phrase is case-insensitive in SQLite. In the future, we might provide an option to make the case-sensitivity locale dependent.
- SQLite doesn’t support pessimistic locking (SELECT FOR UPDATE).
- Streaming of large object data is not supported by SQLite. Hence, when reading or writing data of type
cds.LargeBinaryas a stream the framework temporarily materializes the content. Thus, storing large objects on SQLite may impact the performance.