Created
March 11, 2018 05:40
-
-
Save dhaval201279/bd6a5e9a61c6c2a10cffdb4fd335edad to your computer and use it in GitHub Desktop.
4th version ReservationService - with @Cacheable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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