Reputation: 2621
Does Hazelcast support Distributed and Remote Second Level Cache for Hibernate when using JPA?
I have Client/Server architecture, and my problem is that Data Access Operations using JPA are at the client side..., when the cache is a remote server.
Would please give me a sample of a code to do at the two sides? (at JPA side and Hazelcast side)
Thank you a lot!
Upvotes: 1
Views: 2193
Reputation: 227
First of all, read the docs http://www.hazelcast.org/docs/3.1/manual/html/ch15.html
Simple example of solution in my project (based on spring): 1. include hazelcast hibernate dependency (for maven)
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-hibernate4</artifactId>
<version>${hazelcast.version}</version>
</dependency>
(or hazelcast-hibernate3, if needed)
2.enable cache for hibernate in your persistence-context
<bean id="entityManagerFactory" ... >
<property name="jpaPropertyMap">
<map>
...
<entry key="hibernate.cache.use_second_level_cache" value="true"/>
<entry key="hibernate.cache.use_query_cache" value="true"/>
<entry key="hibernate.cache.region.factory_class" value="com.hazelcast.hibernate.HazelcastCacheRegionFactory"/>
<entry key="hibernate.cache.hazelcast.use_native_client" value="true"/>
<entry key="hibernate.cache.hazelcast.native_client_address" value="127.0.0.1"/>
</map>
</property>
3 .Configure cache for some entities. Profit
Upvotes: 2