Skip to content

Instantly share code, notes, and snippets.

@dhaval201279
Created March 11, 2018 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhaval201279/bd6a5e9a61c6c2a10cffdb4fd335edad to your computer and use it in GitHub Desktop.
Save dhaval201279/bd6a5e9a61c6c2a10cffdb4fd335edad to your computer and use it in GitHub Desktop.
4th version ReservationService - with @Cacheable
@Service
public class ReservationService {
private ReservationRepository reservationRepository;
public ReservationService(ReservationRepository reservationRepository) {
this.reservationRepository = reservationRepository;
}
@Cacheable("reservation")
public Reservation getReservationDetails(String name) {
System.out.println("Entering and leaving ReservationService : getReservationDetails "
+ "after calling reservationRepository.findByFirstName");
Reservation aReservation = reservationRepository.findByFirstName(name);
if (aReservation == null) {
throw new ReservationNotFoundException();
}
return aReservation;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment