java - Not able to configure JPA with ehcache -
i have been trying configure jpa ehcache no success till now. configurations doing :
persistence.xml
<persistence-unit name="customdatabase"> <jta-data-source>jdbc/oraclexe_ds</jta-data-source> <class>com.td.waw.cse.entities.product</class> <properties> <property name="openjpa.log" value="defaultlevel=trace, runtime=info, tool=info, sql=trace"/> <property name="openjpa.querycache" value="net.sf.ehcache.openjpa.datacache.ehcachequerycache"/> <property name="openjpa.datacachemanager" value="net.sf.ehcache.openjpa.datacache.ehcachedatacachemanager"/> <property name="openjpa.datacache" value="net.sf.ehcache.openjpa.datacache.ehcachedatacache"/> <property name="openjpa.remotecommitprovider" value="net.sf.ehcache.openjpa.datacache.noopremotecommitprovider"/> </properties>
ehcache.xml
<ehcache xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="ehcache.xsd" updatecheck="true" monitoring="autodetect" dynamicconfig="true" > <defaultcache maxelementsinmemory="1000" eternal="false" timetoidleseconds="300" timetoliveseconds="600" overflowtodisk="false" memorystoreevictionpolicy="lru" /> <!-- openjpa data cache --> <cache name="openjpa" maxelementsinmemory="5000" eternal="false" timetoidleseconds="300" timetoliveseconds="600" overflowtodisk="false" memorystoreevictionpolicy="lru" /> <!-- openjpa query cache --> <cache name="openjpa-querycache" maxelementsinmemory="1000" eternal="false" timetoidleseconds="300" timetoliveseconds="600" overflowtodisk="false" memorystoreevictionpolicy="lru" /> </ehcache>
product.java
@entity @table(name="product") @namedqueries({@namedquery(name="getallproducts", query = "select products product products")}) public class product implements serializable {}
i not getting exception not see ehcache working nothing specific ehcache printed in logs. appreciate if can in this.
add following properties in persistence.xml:
<property name="openjpa.querycache" value="ehcache"/> <property name="openjpa.datacachemanager" value="ehcache"/>
add following jars in classpath:ehcache-core-2.4.4.jar
, ehcache-openjpa-0.2.0.jar
, slf4j-api-1.6.1.jar
.
that's all.
jar downloads:
- link - http://ehcache.org/downloads/catalog?activated=true
ehcache-core-2.4.4.jar
,slf4j-api-1.6.1.jar
- ehcache-core-2.4.4-distribution.tar.gz moduleehcache-openjpa-0.2.0.jar
- ehcache-openjpa-0.2.0-distribution.tar.gz
references
- l2 caching explained - http://blogs.oracle.com/carolmcdonald/entry/jpa_caching
- openjpa l2 caching implementation - http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_caching.html
- ehcache openjpa implementation - http://www.ehcache.org/documentation/user-guide/openjpa-provider
Comments
Post a Comment