Results 1 to 1 of 1

Thread: Spring,struts2,JPA(Hibernate),EHcache(Second-level cache is not enabled for usage)

  1. #1
    Join Date
    Aug 2012
    Posts
    1

    Question Spring,struts2,JPA(Hibernate),EHcache(Second-level cache is not enabled for usage)

    Hi i am new in JPA EHcache...Integrating JPA(Hibernate) with spring and trying to use EHCache. May be this topic has been discussed ...i am using same and also followed many others website. But not able to resolve the problem.
    my files are following.

    persistence.xml

    Code:
    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
    		  
    <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider" />
    <property name="hibernate.cache.use_second_level_cache" value="true" /> 
     <property name="net.sf.ehcache.configurationResourceName" value="/ehcache.xml" /> 
    <property name="hibernate.cache.use_structured_entries" value="true"/>
     <property name="hibernate.cache.use_query_cache" value="true" /> 
      <property name="hibernate.generate_statistics" value="true" />
    ehcache.xml

    Code:
    <ehcache>
    <diskStore path="java.io.tmpdir"/>
        <defaultCache eternal="true" 
                overflowToDisk="false"
                maxElementsInMemory="50000" 
                timeToIdleSeconds="30" 
                timeToLiveSeconds="6000"
                
                />
        <cache name="com.model.Customer"
                maxElementsInMemory="5000"
                eternal="false"
                overflowToDisk="false"
                />           
        
                </ehcache>
    ApplicationContext.xml

    Code:
    <bean
    		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
    
    	<bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="jpaVendorAdapter">
    			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    				<property name="showSql" value="true" />
    				<property name="generateDdl" value="true" />
    				<property name="databasePlatform" value="${db.dialect}" />
    				 
    			</bean>
    		</property>
    		<property name="persistenceUnitManager" ref="persistenceUnitManager" />
    		<property name="persistenceUnitName" value="testPersUnit" />
    		<property name="dataSource" ref="dataSource"/>
    	</bean>
    
    	<bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager" lazy-init="default">
    		<property name="loadTimeWeaver" ref="loadTimeWeaver" />
    		<property name="persistenceXmlLocations">
    			<list>
    				<value>classpath*:/META-INF/persistence.xml</value>
    			</list>
    		</property>
    		<property name="defaultDataSource" ref="dataSource"/>
    	</bean>
    
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="${db.dataSource}"/>
    	</bean>


    plz give any solutions..thnx in advance.
    Last edited by ravikmr; Aug 28th, 2012 at 01:33 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •