mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:25:50 +00:00
Using the @CacheResult JSR-107 JCache annotation
This commit is contained in:
parent
6ff35b6c22
commit
f78ee5d76e
1 changed files with 6 additions and 10 deletions
|
@ -15,16 +15,9 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.samples.petclinic.model.Owner;
|
||||
import org.springframework.samples.petclinic.model.Pet;
|
||||
import org.springframework.samples.petclinic.model.PetType;
|
||||
import org.springframework.samples.petclinic.model.Vet;
|
||||
import org.springframework.samples.petclinic.model.Visit;
|
||||
import org.springframework.samples.petclinic.model.*;
|
||||
import org.springframework.samples.petclinic.repository.OwnerRepository;
|
||||
import org.springframework.samples.petclinic.repository.PetRepository;
|
||||
import org.springframework.samples.petclinic.repository.VetRepository;
|
||||
|
@ -32,9 +25,12 @@ import org.springframework.samples.petclinic.repository.VisitRepository;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.cache.annotation.CacheResult;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Mostly used as a facade for all Petclinic controllers
|
||||
* Also a placeholder for @Transactional and @Cacheable annotations
|
||||
* Also a placeholder for @Transactional and @CacheResult annotations
|
||||
*
|
||||
* @author Michael Isvy
|
||||
*/
|
||||
|
@ -100,7 +96,7 @@ public class ClinicServiceImpl implements ClinicService {
|
|||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
@Cacheable(value = "vets")
|
||||
@CacheResult(cacheName = "vets")
|
||||
public Collection<Vet> findVets() throws DataAccessException {
|
||||
return vetRepository.findAll();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue