19.8. JPA Cache Store
Important
19.8.1. JPA Cache Store Sample XML Configuration (Library Mode)
infinispan.xml file:
<local-cache name="users">
<!-- Insert additional configuration elements here -->
<persistence passivation="false">
<jpa-store xmlns="urn:infinispan:config:store:jpa:8.0"
shared="true"
preload="true"
persistence-unit="MyPersistenceUnit"
entity-class="org.infinispan.loaders.jpa.entity.User" />
</persistence>
</local-cache>19.8.2. Storing Metadata in the Database
storeMetadata is set to true (default value), meta information about the entries such as expiration, creation and modification timestamps, and versioning is stored in the database. JBoss Data Grid stores the metadata in an additional table named __ispn_metadata__ because the entity table has a fixed layout that cannot accommodate the metadata.
Procedure 19.3. Configure persistence.xml for Metadata Entities
- Using Hibernate as the JPA implementation allows automatic creation of these tables using the property
hibernate.hbm2ddl.autoinpersistence.xmlas follows:<property name="hibernate.hbm2ddl.auto" value="update"/>
- Declare the metadata entity class to the JPA provider by adding the following to
persistence.xml:<class>org.infinispan.persistence.jpa.impl.MetadataEntity</class>
storeMetadata attribute to false in the JPA Store configuration.
19.8.3. Deploying JPA Cache Stores in Various Containers
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jpa</artifactId>
<version>8.3.0.Final-redhat-1</version>
</dependency>
Procedure 19.4. Deploy JPA Cache Stores in JBoss EAP 6.3.x and earlier
- To add dependencies from the JBoss Data Grid modules to the application's classpath, provide the JBoss EAP deployer a list of dependencies in one of the following ways:
- Add a dependency configuration to the
MANIFEST.MFfile:Manifest-Version: 1.0 Dependencies: org.infinispan:jdg-7.0 services, org.infinispan.persistence.jpa:jdg-7.0 services
- Add a dependency configuration to the
jboss-deployment-structure.xmlfile:<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <dependencies> <module name="org.infinispan.persistence.jpa" slot="jdg-7.0" services="export"/> <module name="org.infinispan" slot="jdg-7.0" services="export"/> </dependencies> </deployment> </jboss-deployment-structure>
Procedure 19.5. Deploy JPA Cache Stores in JBoss EAP 6.4 and later
- Add the following property in
persistence.xml:<persistence-unit> [...] <properties> <property name="jboss.as.jpa.providerModule" value="application" /> </properties> </persistence-unit> - Add the following dependencies to the
jboss-deployment-structure.xml:<jboss-deployment-structure> <deployment> <dependencies> <module name="org.infinispan" slot="jdg-7.0"/> <module name="org.jgroups" slot="jdg-7.0"/> <module name="org.infinispan.persistence.jpa" slot="jdg-7.0" services="export"/> <module name="org.hibernate"/> </dependencies> </deployment> </jboss-deployment-structure> - Add any additional dependencies, such as additional JDG modules, are in use add these to the
dependenciessection injboss-deployment-structure.xml.
Important

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.