2011-11-30 2 views
1

최대 절전 모드 3.6.8. 최종Hibernate 예제 조건이 쿼리 캐시에서 작동하지 않습니까?

누구든지 최대 절전 모드에서 예제 criterias가 쿼리 캐시와 함께 작동하는 방법을 알고 있습니다. 내 경우에는 조건에 따라 캐싱을 사용하는 즉시 작동을 멈 춥니 다 (db 내용에 관계없이 결과를 반환하지 않음).

캐시 정의

<cache name="DimensionQueryCache" 
    maxElementsInMemory="100000" 
    eternal="true" 
    overflowToDisk="true" /> 

<cache name="org.hibernate.cache.StandardQueryCache" 
    maxElementsInMemory="100000" 
    eternal="false" 
    timeToIdleSeconds="3600" 
    timeToLiveSeconds="3600" 
    overflowToDisk="false" /> 

최대 절전 모드 설정

:

<persistence-unit name="sqlServerPersistenceUnit" transaction-type="RESOURCE_LOCAL"> 
    <provider>org.hibernate.ejb.HibernatePersistence</provider> 
    <properties> 
     <!-- See Hibernate's Environment class. --> 
     <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" /> 
     <property name="hibernate.ejb.autodetection" value="class" /> 
     <property name="hibernate.default_schema" value="dbo"/> 
     <property name="hibernate.max_fetch_depth" value="2" /> 
     <property name="hibernate.show_sql" value="false" /> 
     <property name="hibernate.format_sql" value="false" /> 
     <property name="hibernate.use_sql_comments" value="false" /> 
     <property name="hibernate.generate_statistics" value="false" /> 
     <!-- If we ever switch to a clustered L2 cache, set hibernate.cache.use_structured_entries to true --> 
     <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider" /> 
     <property name="hibernate.cache.use_second_level_cache" value="true"/> 
     <property name="hibernate.cache.use_query_cache" value="true"/> 
     <property name="hibernate.cache.use_structured_entries" value="false" /> 
     <property name="net.sf.ehcache.configurationResourceName" value="META-INF/ehcache-hibernate.xml" /> 
     <property name="hibernate.cache.provider_configuration_file_resource_path" value="META-INF/ehcache-hibernate.xml" /> 
     <property name="hibernate.default_batch_fetch_size" value="16" /> 
     <property name="hibernate.jdbc.batch_size" value="50" /> 
    </properties> 
</persistence-unit> 

쿼리 : - 나는 setCacheable 제거하고 질의 영역이 잘 작동하는지

Dimension existingCandidate= jpaTemplate.execute(new JpaCallback() { 
     public Object doInJpa(EntityManager em) throws PersistenceException { 
      Session session = (Session) em.getDelegate(); 
      Dimension existingCandidate = (Dimension) session.createCriteria(dimension.getClass()).setCacheable(true).setCacheRegion("DimensionQueryCache").add(Example.create(dimension)).uniqueResult(); 
      return existingCandidate; 
     } 
    }); 

내가 말했듯이.

건배

답변

0

시도는 최대 절전 모드 설정 파일에 SessionFactory를 이름을 지정합니다. 최신 버전의 Hibernate에서 RMI를 통한 캐시 복제를 처리하는 데 문제가있는 것 같습니다 (https://hibernate.onjira.com/browse/HHH-6162 참조).

+0

처음에는 작동하지 않는 것 같습니다. 의미있는 것 같아서 나중에 더 자세히 조사 할 것입니다. – MikePatel

관련 문제