2013-07-27 4 views
0

저는 완전한 스프링 데이터 멍청입니다.스프링 데이터 저장소 캐싱 결과

<cache:annotation-driven /> 

<!-- generic cache manager --> 
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager"> 
    <property name="caches"> 
    <set> 
     <bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean" p:name="UserList"/> 
    </set> 
    </property> 
</bean> 

캐싱 절대적으로 아무것도하지 않는 :

public interface UserBalanceRepository extends PagingAndSortingRepository<UserBalance, Integer> 
{ 
    @Cachable("UserList") 
    @Query("select userId from UserBalance") 
    List<Integer> ListUserIds(Pageable pageable); 
} 

내 캐시 구성은 다음과 같다 다음과 같이 나는 인터페이스를 가지고있다. 프록시 클래스가 @Cachable 주석을 가지고 있지 않기 때문에 그런 것 같지만 어떻게 캐싱 작업을해야합니까? 캐싱을 수행하는 다른 방법이 있습니까?

내 마지막 수단은 래퍼 클래스 내에 캐시되어야하는 호출을 넣고 거기에 캐시하는 것입니다.

+0

캐싱 설정은 어떻게됩니까? –

+0

매우 기본입니다. 방금 전 예제를 사용했습니다. 하지만 AspecJ는 인터페이스에서 pointcut을 만들지 않을 것이라는 점을 이해합니다. – Leon

+0

전혀 관련된 AspectJ가 없습니다. 캐싱 구성을 추가하십시오. 그렇지 않으면 진행 상황을 판단하기가 어렵습니다. '@ Cacheable'을 사용하면 캐싱을 올바르게 구성한 것처럼 보여줍니다. –

답변

0

나는 같은 문제에 직면했다. 귀하의 코드는 내 것과 동일합니다. eclipseLink를 사용하고 있으며 persistence.xml에서 캐싱을 활성화해야했습니다. 방금 속성을 추가했습니다.

 [...] 
     <class>com.project.web.model.entity.ReturnOrder</class> 
     <class>com.project.web.model.entity.BillingAddress</class> 
     <exclude-unlisted-classes>false</exclude-unlisted-classes> 
     <properties> 
      <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://connection string"/> 
      <property name="javax.persistence.jdbc.user" value="user"/> 
      <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/> 
      <property name="javax.persistence.jdbc.password" value="pass"/> 

      <!-- PROPERTY ADDED --> 
      <property name="eclipselink.cache.shared.default" value="true"/> 
     </properties> 
    </persistence-unit> 
</persistence> 

또한 this은 아주 좋은 자습서입니다.