9.3 JPA database resources
9.3.1 Setup
Using the JPA database resources is straightforward, simply follow the steps below.
If you have generated a project using an archetype, then depending on the selected archetype these steps might already have been done for you.
9.3.1.1 Create some JPA entities
In your Kauri module, add some POJO's you want to persist. Annotate them with JPA annotations, only @Entity is required.
9.3.1.2 Create a persistence.xml
Add a META-INF/
The default persistence-unit name is "kauri-dbresources". If you use another one, you need to define it using a Spring bean named "persistenceUnitName", see below.
9.3.1.3 Update the pom.xml
In the pom.xml of your module, add a dependency on the kauri-dbresources-impl artifact:
<dependency>
<groupId>org.kauriproject</groupId>
<artifactId>kauri-dbresources-impl</artifactId>
<version>${version.kauri}</version>
</dependency>
9.3.1.4 Spring bean configuration
In your spring bean configuration (src/main/kauri/spring/...), add the following import:
<import resource="classpath:org/kauriproject/dbresources/jpa/services.xml"/>
If needed override the default persistenceUnitName by adding:
<bean id="persistenceUnitName" class="java.lang.String">
<constructor-arg value="{your-persistency-unit-name-here}"/>
</bean>
9.3.1.5 wiring.xml
The import we did in the Spring configuration will automatically export a REST-service called jpaRestlet.
In the wiring.xml, you can mount this REST-service on a path of your choice.
Inside the XML-element defining your module, add: <mount name="jpaRestlet" path="/data"/>
9.3.1.6 Try it out
After doing an "mvn install" and (re)starting Kauri, browse to:
http://localhost:8888/data/myentity
where myentity corresponds to the name of an entity as annotated on your Java classes, such as @Entity(name = "myentity")
Previous