Hibernate Second Level Cache
This is the manual for older MicroStream versions (Version < 5.0).
The new documentation (Version >= 5.0) is located at:
MicroStream offers a Hibernate cache region factory, which can be found in the cache.hibernate module.
pom.xml
1
<repositories>
2
<repository>
3
<id>microstream-releases</id>
4
<url>https://repo.microstream.one/repository/maven-public/</url>
5
</repository>
6
</repositories>
7
<dependencies>
8
<dependency>
9
<groupId>one.microstream</groupId>
10
<artifactId>cache.hibernate</artifactId>
11
<version>04.01.00-MS-GA</version>
12
</dependency>
13
</dependencies>
Copied!
The region factory's class name is one.microstream.cache.hibernate.CacheRegionFactory. It is configured via the property hibernate.cache.region.factory_class.
Depending on your environment it can be configured in different ways.
If you use a good old persistence.xml, set the property there:
persistence.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<persistence version="2.1"
3
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
4
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
6
<persistence-unit name="...">
7
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
8
...
9
<properties>
10
...
11
<property name="hibernate.cache.region.factory_class"
12
value="one.microstream.cache.hibernate.CacheRegionFactory" />
13
...
14
</properties>
15
</persistence-unit>
16
</persistence>
Copied!
Or for Spring applications:
application.properties
application.yml
1
spring.jpa.properties.hibernate.cache.microstream.missing_cache_strategy=create
2
spring.jpa.properties.hibernate.cache.region.factory_class=one.microstream.cache.hibernate.CacheRegionFactory
3
spring.jpa.properties.hibernate.cache.use_query_cache=true
4
spring.jpa.properties.hibernate.cache.use_second_level_cache=true
5
spring.jpa.properties.javax.persistence.sharedCache.mode=ALL
Copied!
1
spring:
2
jpa:
3
properties:
4
hibernate:
5
cache:
6
microstream:
7
missing_cache_strategy: create
8
region:
9
factory_class: one.microstream.cache.hibernate.CacheRegionFactory
10
use_query_cache: true
11
use_second_level_cache: true
12
javax:
13
persistence:
14
sharedCache:
15
mode: ALL
Copied!
Last modified 4mo ago
Export as PDF
Copy link