Ce contenu n'est pas disponible dans la langue sélectionnée.
18.8. JPA Cache Store
Important
18.8.1. JPA Cache Store Sample XML Configuration (Library Mode) Copier lienLien copié sur presse-papiers!
infinispan.xml
file:
18.8.2. JPA Cache Store Sample Programmatic Configuration Copier lienLien copié sur presse-papiers!
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(JpaStoreConfigurationBuilder.class).persistenceUnitName("org.infinispan.loaders.jpa.configurationTest") .entityClass(User.class) .build();
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(JpaStoreConfigurationBuilder.class).persistenceUnitName("org.infinispan.loaders.jpa.configurationTest")
.entityClass(User.class)
.build();
- The
persistenceUnitName
parameter specifies the name of the JPA cache store in the configuration file (persistence.xml
) that contains the JPA entity class. - The
entityClass
parameter specifies the JPA entity class that is stored in this cache. Only one class can be specified for each configuration.
18.8.3. Storing Metadata in the Database Copier lienLien copié sur presse-papiers!
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 18.7. Configure persistence.xml for Metadata Entities
- Using Hibernate as the JPA implementation allows automatic creation of these tables using the property
hibernate.hbm2ddl.auto
inpersistence.xml
as follows:<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Declare the metadata entity class to the JPA provider by adding the following to
persistence.xml
:<class>org.infinispan.persistence.jpa.impl.MetadataEntity</class>
<class>org.infinispan.persistence.jpa.impl.MetadataEntity</class>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
storeMetadata
attribute to false
in the JPA Store configuration.
18.8.4. Deploying JPA Cache Stores in Various Containers Copier lienLien copié sur presse-papiers!
<dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-cachestore-jpa</artifactId> <version>6.3.0.Final-redhat-5</version> </dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jpa</artifactId>
<version>6.3.0.Final-redhat-5</version>
</dependency>
Procedure 18.8. 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.MF
file:Manifest-Version: 1.0 Dependencies: org.infinispan:jdg-6.5 services, org.infinispan.persistence.jpa:jdg-6.5 services
Manifest-Version: 1.0 Dependencies: org.infinispan:jdg-6.5 services, org.infinispan.persistence.jpa:jdg-6.5 services
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add a dependency configuration to the
jboss-deployment-structure.xml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 18.9. Deploy JPA Cache Stores in JBoss EAP 6.4 and later
- Add the following property in
persistence.xml
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the following dependencies to the
jboss-deployment-structure.xml
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add any additional dependencies, such as additional JDG modules, are in use add these to the
dependencies
section injboss-deployment-structure.xml
.
Important