Database Schemas

In the same way that Java packages act as a namespace for domain objects, it’s good practice to map domain entities to their own (database) schemas. (For more on database schemas, see for example here).

We recommend all the entities within a module use the same schema, and moreover that the logical type name also follows the same pattern.

For example, SecMan' JPA implementation resides in the CausewayModuleExtSecmanPersistenceJpa module. Its ApplicationUser entity is defined as:

ApplicationUser.java
@Entity
@Table(
        schema = "causewayExtSecman",
        name = "ApplicationUser",
        ...
)
public class ApplicationUser ... { /* ... */ }

which results in a CREATE TABLE statement of:

CREATE TABLE causewayExtSecman."ApplicationUser" (
    ...
)

Configuring Schemas

While it is good practice to place tables in schemas, the ORMs do not by default actually create those schema (as per CREATE SCHEMA statement).

The framework therefore allows this to be configured: