Search

Development

Content

Application Configuration

This section describes how to configure applications.

SQLite

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.

File-Based Storage

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 never.

---
spring:
  profiles: sqlite
  datasource:
    url: "jdbc:sqlite:sqlite.db"
    driver-class-name: org.sqlite.JDBC
    initialization-mode: never
    hikari:
      maximum-pool-size: 1

In-Memory Storage

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 always.

---
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.

PostgreSQL

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:

  1. CDS doesn’t yet support PostgreSQL specific database schema generation.
  2. There’s no support for Schema Evolution for PostgreSQL.
  3. Localization is supported just as in SQLite:
    • PostgreSQL doesn’t support the SESSION_CONTEXT method to dynamically determine the locale from a connection.
    • Instead, cds creates two SQL views for the languages German and French by default, to be able to determine the locale at runtime.
  4. The sort order of any query on PostgreSQL will behave as configured on the database.

SQLite

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.

  1. Localization is only supported currently for ‘de’, ‘fr’ and a default locale. We’ll in the near future provide support for all other locales.
  2. Any views generated for SQLite are read-only by default, inserting records can only happen with a one to one projection.
  3. 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.
  4. The predicate function contains is 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.
  5. SQLite doesn’t support pessimistic locking (SELECT FOR UPDATE).
  6. Streaming of large object data is not supported by SQLite. Hence, when reading or writing data of type cds.LargeString and cds.LargeBinary as a stream the framework temporarily materializes the content. Thus, storing large objects on SQLite may impact the performance.