この回答に触発されて、私は次のことを試みました
@NoRepositoryBean
public interface CacheableRepository<T, ID extends Serializable>
extends JpaRepository<T, ID>, JpaSpecificationExecutor<T>, PagingAndSortingRepository<T, ID> {
@Cacheable()
T findOne(ID id);
@Cacheable()
List<T> findAll();
@Cacheable()
Page<T> findAll(Pageable pageable);
@CacheEvict(allEntries = true)
<S extends T> S save(S entity);
@CacheEvict(allEntries = true)
void delete(ID id);
}
次に、このインターフェイスを使用して、使用済みリポジトリを定義します
@CacheConfig(cacheNames={"uniqueCache"})
public interface SomeObjectRepo extends CacheableRepository<SomeObject, Long> {
@Cacheable(key = "someobject+#p0")
List<SomeObject> findByType(Integer type);
@Cacheable(key = "someobject+#p0")
List<SomeObject> findByCategory(String field);
@Cacheable(key="someobject+#p0.concat(#p1)")
List<SomeObject> findByCategoryAndWizardType_id(String field,Integer id);
}
作品:
上記のキャッシュはfindByType、、、findByCategoryfindByCategoryAndWizardType_id
動作しません:
で定義されたすべてのcacheableメソッドに対してCacheableRepository。のCacheConfig注釈SomeObjectRepoは影響しないようCacheableRepositoryです。
私の質問:
注釈が機能しないのはなぜですか? この構造を機能させるための回避策はありますか?
ありがとう、オーク