I want to add \"Cacheable\" annotation in findOne method, and evict the cache when delete or happen methods happened.
How can I do that ?
I solved the this in the following way and its working fine
public interface BookRepositoryCustom {
Book findOne(Long id);
}
public class BookRepositoryImpl extends SimpleJpaRepository implements BookRepositoryCustom {
@Inject
public BookRepositoryImpl(EntityManager entityManager) {
super(Book.class, entityManager);
}
@Cacheable(value = "books", key = "#id")
public Book findOne(Long id) {
return super.findOne(id);
}
}
public interface BookRepository extends JpaRepository, BookRepositoryCustom {
}