Setup and Configuration
This section describes how to include the JPA module and setup its configuration properties.
Maven pom.xml
Dependency Management
If your application inherits from the Apache Causeway starter app (org.apache.causeway.app:causeway-app-starter-parent
) then that will define the version automatically:
<parent>
<groupId>org.apache.causeway.app</groupId>
<artifactId>causeway-app-starter-parent</artifactId>
<version>3.1.0</version>
<relativePath/>
</parent>
Alternatively, import the core BOM. This is usually done in the top-level parent pom of your application:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.causeway.core</groupId>
<artifactId>causeway-core</artifactId>
<version>3.1.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
Update AppManifest
In your application’s AppManifest
(top-level Spring @Configuration
used to bootstrap the app), import the
@Configuration
@Import({
...
CausewayModuleJpaEclipselink.class,
...
})
public class AppManifest {
}
DataSource
The JPA object store uses Spring to provide a javax.sql.DataSource
.
Normally this is done by setting the spring.datasource
configuration properties, as described in the
Spring Boot documentation.
For example, the SimpleApp starter app defines these:
-
for H2 (in-memory):
app.propertiesspring.sql.init.platform=h2 spring.datasource.url=jdbc:h2:mem:simple spring.datasource.driver-class-name=org.h2.Driver
-
for SQL Server:
app.propertiesspring.sql.init.platform=sqlserver spring.datasource.url=jdbc:sqlserver://localhost;databaseName=simpleapp spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver spring.datasource.username=simpleapp spring.datasource.password=simpleapp
It is also possible to programmatically define a DataSource
; see the Spring docs for details.
EclipseLink Configuration Properties
The following configuration properties are set by default:
-
is set to
false
-
is set to
create-or-extend-tables
-
javax.persistence.bean.manager
is set to an Apache Causeway implementation, to assist with dependency injection into entities.
Generally these should not be changed, though if there is a requirement, then provide a subclasse alternate implementation of org.apache.causeway.persistence.jpa.eclipselink.config.ElSettings
with an earlier @Priority
precedence.
To set other EclipseLink configuration properties, use a subclass of CausewayModulePersistenceJpaEclipselink and override getVendorProperties()
.
Other Configuration Properties
The JPA object store also supports the following configuration properties:
-
causeway.persistence.schema.additional-orm-files
Lookup additional "mapping-files" in
META-INF/orm-name.xml
(equivalent to "mapping-file" entries inpersistence.xml
) and adds these to those that are already configured the Spring Data way (if any).