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 object type also follows the same pattern.

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

ApplicationUser.java
import javax.jdo.annotations.PersistenceCapable;

@PersistenceCapable(
        schema = "causewayExtSecman",
        table = "ApplicationUser",
        ...
)
public class ApplicationUser ... { /* ... */ }

which results in a CREATE TABLE statement of:

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

If for some reason you don’t want to use schemas (though we strongly recommend that you do), then note that you can override the @PersistenceCapable annotation by providing XML metadata (the mappings.jdo file). See the section on configuring DataNucleus Overriding Annotations for more details.

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: