Java Persistence API (JPA) is a standard JavaEE API for developing applications that need access to relational databases.
To use JPA in your application, you need to add the JPA dependency:
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jpa</artifactId>
</dependency>
and then specify the dependency for whichever JDBC Driver you need for your particular database.
Examples include:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
The jpa
fraction makes the JPA APIs available to your application through a transitive dependency.
There is no need to add them yourself.
By default, inclusion of the jpa
fraction will cause the creation of the default ExampleDS
datasource for usage by your persistence.xml
.
The datasource is bound as the default datasource, so there is no need to reference it by name from your persistence.xml
.
If you have a .jar
-based application with a main(…)
, you can configure multiple datasources for usage with JPA.
Please see the Datasources chapter for details on configuring datasources.
If the default datasource for JPA is used, it may be configured using system properties.
Property | Description |
---|---|
|
JDBC connection URL |
|
Username for authenticating the connection |
|
Password for authenticating the connection |
|
Simple name of the datasource, such as |