2016-08-04 6 views
4

spring3.x에서 spring4.3.x로 마이그레이션 중입니다. 나는 스프링 4.3.0.RELEASE을 사용하고spring4.3.x에서 'entityCacheStrategies'를 구성하는 방법

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'entityCacheStrategies' of bean class [org.springframework.orm.hibernate5.LocalSessionFactoryBean]: Bean property 'entityCacheStrategies' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:242) 
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423) 
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280) 
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) 
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514) 
... 66 more 

나는 다음과 같은 오류를 얻고있다

<bean id="sessionFactory" 
     class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> 
    <property name="annotatedClasses"> 
     <list> 
      <value>com.example.person.domain.Person</value> 
     </list> 
    </property> 

    <property name="mappingLocations"> 
     <list> 
      <value>classpath*:com/example/person/domain/Person.hbm.xml</value> 
     </list> 
    </property> 

    <property name="hibernateProperties"> 
     <props> 
      <prop key="hibernate.dialect">${hibernate.dialect}</prop> 
      <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> 
      <prop key="hibernate.cache.use_query_cache">true</prop> 
      <prop key="hibernate.cache.provider_class">${cache.providerClass}</prop> 
      <prop key="hibernate.generate_statistics">true</prop> 
      <prop key="hibernate.memcached.dogpilePrevention">true</prop> 
      <prop key="hibernate.memcached.servers">${cache.memcached.servers}</prop> 
      <prop key="hibernate.memcached.keyStrategy">com.example.memcached.ExampleCacheStringKeyStrategy</prop> 
      <prop key="hibernate.memcached.deviceAttributeDao.keyStrategy">com.googlecode.hibernate.memcached.HashCodeKeyStrategy</prop> 
      <prop key="hibernate.memcached.EncodingDao.keyStrategy">com.googlecode.hibernate.memcached.HashCodeKeyStrategy</prop> 
     </props> 
    </property> 

    <property name="entityCacheStrategies"> 
     <props> 
      <prop key="com.example.person.domain.TestAttribute">read-write,_domain</prop> 
     </props> 
    </property> 

    <property name="dataSource" ref="dataSource"/> 
</bean> 

을 다음과 같이 나는 콩 창조 org.springframework.orm.hibernate5.LocalSessionFactoryBean 사용하고 있습니다. LocalSessionFactoryBean에는 entityCacheStrategies에 대한 설정자가 없습니다. spring4.3.x에서 이것을 지원하는 방법은 무엇입니까?

답변

1

최대 절전 모드 5에서 entityCacheStrategies/setEntityCacheStrategies()의 사용이 더 이상 사용되지 않습니다. org.hibernate.cfg.Configuration : setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy)에서 가능한 대안은 더 이상 사용되지 않습니다.

그러나 최대 절전 모드 특수 효과 라이브러리를 사용하여 캐시를 구성하려면 CacheConcurrencyStrategy 열거자를 사용하는 this approach을 시도하십시오. 적절한 Concurrency 전략을 Entity 수준에 적용 할 수 있습니다.

@Entity 
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY) 
public class Clazz{..} 

dev guide에서 CacheConcurrencyStrategy 더 많은 용도를 찾아주세요.